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

        currentPatrolCheckpointIndex = (currentPatrolCheckpointIndex + 1) % patrolCheckpointsLength;
        agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex];
    }
Exemple #2
0
    private void PerformPatrol(FollowAgent agent)
    {
        NavMeshAgent navMeshAgent = agent.GetNavMeshAgent();

        if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance)
        {
            SetNextCheckpoint(agent);
        }
    }
Exemple #3
0
 public void OnEnterState(FollowAgent agent)
 {
     if (agent.LastPatrolCheckpointIndex > 0)
     {
         currentPatrolCheckpointIndex = agent.LastPatrolCheckpointIndex;
     }
     else
     {
         currentPatrolCheckpointIndex = 0;
     }
     agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex];
 }
Exemple #4
0
    public void Update(FollowAgent agent)
    {
        bool shouldFollowTarget = agent.ReachedTargetFollowingThreshold();

        if (shouldFollowTarget)
        {
            agent.GetNavMeshAgent().destination = agent.GetFollowTarget().transform.position;
        }
        else
        {
            SwitchToPatrolState(agent);
        }
    }