public NavMeshPathStatus SetDestination(AIDestination AIDestination) { /// When a different path is calculated, we manually reset the path and calculate the next destination /// The input world destination may not be exactly on NavMesh. /// So we do comparison between world destination if (lastSettedWorldDestination != AIDestination.WorldPosition) { // Debug.Log(MyLog.Format("Set destination : " + AIDestination.WorldPosition)); this.currentDestination = AIDestination; objectAgent.ResetPath(); var path = CreateValidNavMeshPathWithFallback(objectAgent, AIDestination.WorldPosition, 50); objectAgent.SetPath(path); if (path.status != NavMeshPathStatus.PathInvalid) { /// If direction change is occuring when current destination has been reached /// We manually calculate next position to avoid a frame where AI is standing still if (FrameWereOccuredTheLastDestinationReached == Time.frameCount) { this.ManuallyUpdateAgent(this.objectAgent); } } else { this.currentDestination = null; } lastSettedWorldDestination = AIDestination.WorldPosition; return(path.status); } else { /// When we try to set a destination that is equal to the lastSettedWorldDestination /// and that the destination has already been reached. /// We also call the on destination reached callback (some external algorithm may have logic in this case.) if (this.IsDestinationReached()) { OnAIInteractiveObjectDestinationReached?.Invoke(); } return(NavMeshPathStatus.PathComplete); } }
public void SetDestination(AIDestination AIDestination) { //When a different path is calculated, we manually reset the path and calculate the next destination //The input world destination may not be exactly on NavMesh. //So we do comparison between world destination if (lastSuccessfulWorldDestination != AIDestination.WorldPosition) { // Debug.Log(MyLog.Format("Set destination : " + AIDestination.WorldPosition)); this.currentDestination = AIDestination; objectAgent.ResetPath(); var path = CreateValidNavMeshPathWithFallback(objectAgent, AIDestination.WorldPosition, 50); objectAgent.SetPath(path); //If direction change is occuring when current destination has been reached //We manually calculate next position to avoid a frame where AI is standing still if (FrameWereOccuredTheLastDestinationReached == Time.frameCount) { ManuallyUpdateAgent(); } lastSuccessfulWorldDestination = AIDestination.WorldPosition; } }
public ForwardAgentMovementCalculationStrategy(AIDestination aiDestination) { AiDestination = aiDestination; }
public LookingAtAgentMovementCalculationStrategy(AIDestination aiDestination, Transform targetLook) { AiDestination = aiDestination; TargetLook = targetLook; }
public void SetDestination(AIDestination AIDestination) { AIDestinationMoveManager.SetDestination(AIDestination); }
public override void SetAIDestination(AIDestination AIDestination) { AIMoveToDestinationSystem.SetDestination(AIDestination); }
public virtual void SetAIDestination(AIDestination AIDestination) { }