- Home /
How set navmesh agent facing rotation prior to next move?
I have my navmesh agent move from point A to point B, once I arrive a point B I do some other logic to make my agent (who ends facing in the last direction of travel). I then face a target by setting the game object's rotation to turn and face a target as it is stationary. Now as soon as I tell the agent to nav to a new location, it snaps back to the last facing direction at the end of the navigation.
My desire is that the navigation gets set up to use the current facing location on any new move, I can't seem to figure out how to tell it to do this.
P.S. I tried ClearPath() and .Stop() before calling SetDestination(newDest) thinking that had to be the reason but still the facing direction always snaps back to the last navmesh computed heading.
Answer by drastick · Jun 18, 2012 at 06:39 AM
I'm not thrilled about the interface for this but I've figure out something that will work here.
If I say durring my destination setup...
navAgent.updatePosition = true;
navAgent.updateRotation = true;
navAgent.SetDestination(destination.Value);
then once I reach my destination set...
navAgent.updatePosition = false;
navAgent.updateRotation = false;
This now allows my rotation and position sets out side of my navigation state to stick and the NavMeshAgent will accept that as the current value.
Answer by Rixly239 · Apr 06, 2016 at 02:35 AM
Thanks. I tried the same, then remove the "true" statements. Seems you only need the "false"
This should be a comment ins$$anonymous$$d of an anwser... just saying
Your answer
Follow this Question
Related Questions
Best way to rotate a NavMesh AI to face the player or a specific direction? 0 Answers
Need some help with Navmesh agents backing off from player / circling player please. 0 Answers
NavMeshAgent resume original position and facing direction C# 0 Answers
Can you randomise a Navmesh agents rotation 1 Answer
Keep AI from flipping? 1 Answer