示例#1
0
    private void SetNextCheckpoint(FollowAgent agent)
    {
        int patrolCheckpointsLength = agent.GetPatrolCheckpoints().Length;

        currentPatrolCheckpointIndex = (currentPatrolCheckpointIndex + 1) % patrolCheckpointsLength;
        agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex];
    }
示例#2
0
 public void OnEnterState(FollowAgent agent)
 {
     if (agent.LastPatrolCheckpointIndex > 0)
     {
         currentPatrolCheckpointIndex = agent.LastPatrolCheckpointIndex;
     }
     else
     {
         currentPatrolCheckpointIndex = 0;
     }
     agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex];
 }
示例#3
0
    public void Update(FollowAgent agent)
    {
        bool shouldFollowTarget = agent.ReachedTargetFollowingThreshold();

        if (shouldFollowTarget)
        {
            SwitchToFollowTargetState(agent);
        }
        else
        {
            if (agent.GetPatrolCheckpoints().Length != 0)
            {
                PerformPatrol(agent);
            }
        }
    }