Nothing was wiggling until i started working on forcing my navmeshagent to rotate before moving using transform.rotation directly. Now that it is rotating to face the other object it has a slight tilt on the x and z axis. I believe that this very slight .01 tilt is causing the navmeshagent to slide very slowly and/or wiggle a bit. How can i disable this? I tried directly altering the rotation angles so that it would never rotate on the x and z axis at all but it seems to not care that i put 0 for the rotation values. It still rotates about .01 on x or z. Can i fix this using the navmeshagent component directly? Or does someone know why my gameObject ignores the fact that i’m telling it to rotate (0, other.y, 0) and has a .01 rotation on x or z despite it.
With extensive research i have found how to rotate around the y axis in the update loop without using slerp (because that slows down towards the end of the rotation if done within the update loop). While this isn’t technically in the update loop, it is called every frame when the player inputs the correlating commands.
Vector3 forward;
Vector3 toOther;
Vector3 toOtherFlat;
Vector3 newDir;
forward = transform.TransformDirection (Vector3.forward);
void Rotate(RaycastHit hit) {
toOther = (hit.point - transform.position).normalized;
toOther.y = 0;
newDir = Vector3.RotateTowards (transform.forward, toOther, Time.deltaTime * 5f, 1f);
transform.rotation = Quaternion.LookRotation (newDir);
}