- Home /
NavMesh Agent doesn't rotate
Hey guys! I have been working on a top down RPG, and everything is working like a charm, except for my Knight AI. You see, all of my other navmesh agents in game, including followers rotate normally to their destination once given an order. Problem is, it just doesn't work on my Knight.
I checked if the problem was on the animations, but none of them affect the Knight's rotation at all, and using LookAt doesn't work either. It's rotation on the Y axis keeps at 180, and it even walks backwards! Any idea of what could be causing that?
Answer by twda · Aug 13, 2017 at 01:38 AM
I guess you have a rigidbody on your knight...? If yes, does this help?
// rotate towards a vector
var qTo = Quaternion.LookRotation(uDir);
qTo = Quaternion.Slerp(transform.rotation, qTo, 30.0f * Time.deltaTime);
_rigidBody.MoveRotation(qTo);
I've fought with a similar problem during the last days, and I suspect that the NavMeshAgent needs some speed / walking before it can / does rotate, but I may be wrong about it. At least, for me, the NavMeshAgent wouldn't rotate if the character wasn't moving.
Or did you accidentally check FreezePosition / FreezeRotation on the Knight?
Indeed, i am using a Rigidbody. Unfortunately, it didn't work.
Hmmm, did you try to isolate the problem by commenting out some parts of your AI script? I'd really like to help, but the info you provide is currently a bit sparse.
Ok, seems like the problem is with the Animator, which is even worse.If i rotate the $$anonymous$$night while running the game, it resets (Won't change). If i disable the animator, it does change the rotation.
What made it worse is the simple fact that none of the animations change rotation, AND i couldn't find a single problem on the animator itself. Any hint?
I've posted a bug report a few days ago where the character wouldn't rotate a child object (in my case the neck and head) if root motion as used. Unity confirmed it's a bug. Not sure if you're dealing with the same. To be sure, you'd need to post a bug report, and you'll get a reply if you're doing something wrong or if it's a bug. You can easily report a bug from within Unity, it's really convinient.
Looks like unchecking and then checking root motion again made it fix itself. Still, thanks for the help ^.^
Your answer
Follow this Question
Related Questions
Is it right to turn false both navmeshagent updateRotation and updatePosition properties ? 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How can i make my soldier to patrol over the space station in random ? 1 Answer
Unity Navmesh agent patrol and chase player script issues. 0 Answers