private void SetNextCheckpoint(FollowAgent agent) { int patrolCheckpointsLength = agent.GetPatrolCheckpoints().Length; currentPatrolCheckpointIndex = (currentPatrolCheckpointIndex + 1) % patrolCheckpointsLength; agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex]; }
public void OnEnterState(FollowAgent agent) { if (agent.LastPatrolCheckpointIndex > 0) { currentPatrolCheckpointIndex = agent.LastPatrolCheckpointIndex; } else { currentPatrolCheckpointIndex = 0; } agent.GetNavMeshAgent().destination = agent.GetPatrolCheckpoints()[currentPatrolCheckpointIndex]; }
public void Update(FollowAgent agent) { bool shouldFollowTarget = agent.ReachedTargetFollowingThreshold(); if (shouldFollowTarget) { SwitchToFollowTargetState(agent); } else { if (agent.GetPatrolCheckpoints().Length != 0) { PerformPatrol(agent); } } }