I have some code to manage to rotation of my Navmesh agents:
if (Agent.isActiveAndEnabled && Agent.hasPath)
{
if (Agent.velocity.sqrMagnitude > Mathf.Epsilon)
{
transform.rotation = Quaternion.LookRotation(Agent.velocity.normalized);
}
}
It's causing my some issues with some odd rotations on the x/z axis for 1-2 frames every now and then, is there some way I can get this exact behaviour but only modify the y-axis?
Quaternion tempRot = transform.rotation = Quaternion.LookRotation(Agent.velocity.normalized); tempRot.x = 0; tempRot.z = 0; transform.rotation = tempRot;
\$\endgroup\$ – Majs Jan 11 '20 at 11:01