Support Forum

AIPath and rigidbodies

Hi, Im trying to better understand how AIPath and AIBase move rigidbodies. All of my units I need to move around are driven by physics, with non kinematic rigidbodies. In AIBase, line 579 you have
if (rigid != null) rigid.MoveRotation(nextRotation);
from my understanding, .MoveRotation (and MovePosition) only work on kinematic rigidbodies. Is there something else in the code that is allowing it to work with my non kinematic rigidbodies, because it does seem to move them, I am not sure why. I was expecting to find .AddForce or .AddTorque as I understand those are the only ways you should be moving non kinematic rigidbodies. Or is the code only compatible with kinematic ones?

Id also like to tweak the rotation, it seems to be instantaneous and doesn’t look natural for movement. Even lowering the speed it seems to flick back and forth when close the direction of travel.

It’s not unnatural, it moves very naturally. Also, those functions work on any rigidbodies, and AddForce and AddTorque, as well as setting velocity, are only good for realistic movement which usually is only for simple stuff. I don’t know how to explain it but their method makes more sense.