예제 #1
0
        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);
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 public ForwardAgentMovementCalculationStrategy(AIDestination aiDestination)
 {
     AiDestination = aiDestination;
 }
예제 #4
0
 public LookingAtAgentMovementCalculationStrategy(AIDestination aiDestination, Transform targetLook)
 {
     AiDestination = aiDestination;
     TargetLook    = targetLook;
 }
예제 #5
0
 public void SetDestination(AIDestination AIDestination)
 {
     AIDestinationMoveManager.SetDestination(AIDestination);
 }
예제 #6
0
 public override void SetAIDestination(AIDestination AIDestination)
 {
     AIMoveToDestinationSystem.SetDestination(AIDestination);
 }
예제 #7
0
 public virtual void SetAIDestination(AIDestination AIDestination)
 {
 }