Hi, I am working on a wild life simulation game. I am really stuck at surface orientation of navmesh ai. I have 200+ animals on a scene. So, i need a simple solution for this.
Problem:
Fix:
Problem:
Fix:
and i am not very good at coding so, can you give me code examples instead of ideas please. Thanks.
You don’t really want to be rotating the nav mesh agent, you want to rotate the model.
there are a few ways of doing that, you can use Inverse Kinematics, Mechanim, triggers, or just code(the easiest way).
I’m not going to give any code since that wastes my time and doesn’t teach anything.
However the way I would approach it is this:
Raycast into the floor and find the normal direction of the hit. (This is the hit.normal)
Invert this vector.
Apply this as a rotation to the model. (As a child of the Agent, don’t rotate the agent itself)
How frequently you do this is up to you, you could do this in an Update to start with, but I’d refine it and probably combine it with triggers eventually.