I am using a navmesh agent for my AI, but while walking it just doesn’t rotate correctly? It does some rotations, but it doesn’t rotate to face his movement vector, using transform.lookat doesn’t do anything
Make sure your character is laid out so that:
-
when placed in a scene with rotations (0,0,0)
-
the “forward” is going towards the world +Z
9bviez
Here’s how it looks, every 4 seconds it gets a new random .setdestination to the navmesh agent, but it doesn’t rotate. Yes the character is rotation 0,0,0 at the start. Not sure what “forward” world is in this scenario
Whatever that is going on, I like it! Neat spooky forest surroundings.
The NavMeshAgent should be turning you towards motion, but it’s possible this is no longer the case, or that it is a settable option in the NavMeshAgent. I haven’t used one lately so take a look in the inspector for it.
It’s also possible that something else is forcing your geometry to rotate in a particular way. To me it looks incorrectly tilted, but I’m not sure what exactly you’re going for.
To isolate further, make another character with a Unity box or something and see what it does when told to go places in the navmesh.
It worked fine on a new cube, but somehow didn’t work on the model so I checked the behavior code and turns out I was rotating the player to face the camera and not it’s UI. Well that’s unlucky
It always feels good when investigation turns up real results.
Or is it perhaps a new opportunity to think about how you can design into this!