unity – desired velocity and the local space z axis

This question is related to my previous post here , but, even though I did get some insight, I didn’t fully get it, and hence have another dilemma. Since enter link description here the series is not publicly available, I’ll try to explain as much as possible.

Initial around 21:35 timecode of the lesson 13 of the series, the author tries to find the direction the navMeshAgent should turn. For this, he applies the sign of the cross product between desiredVelocity vector and the local z-axis of the navMeshAgent. If the result was negative, he turns left, if positive he turns right. Note that here, he does not convert the desiredVelocity vector to the navMeshAgent‘s local space.

But, later, we come to a case where we require the angle between the desiredVelocity vector and the navMeshAgent‘s local z-axis. In this case, he does convert the desiredVelocity vector to the local space of the navMeshAgent using transform.InverseTransformVector(desiredVelocity). I don’t really get the concept behind it. Why are we not converting the desiredVelocity vector to localSpace in the former case? Obviously the direction might change from conversion of one space to another, so the result should be affected. Please help me understand this. Thanks in advance.

Source link

More To Explore

Share on facebook
Share on twitter
Share on linkedin
Share on email