x


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.

more ▼

asked Jun 16 '12 at 08:01 AM

drastick gravatar image

drastick
226 8 10 18

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.

Jun 16 '12 at 08:13 AM drastick
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jun 18 '12 at 06:39 AM

drastick gravatar image

drastick
226 8 10 18

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2241
x982
x78
x5

asked: Jun 16 '12 at 08:01 AM

Seen: 1736 times

Last Updated: Jun 18 '12 at 06:41 AM