Stop NavMeshAgent from rotating ALL axises?

I’m using a navmesh with my 2d game, and setting the updateRotation to false only stops the Z axis from rotating. I can’t stop my agent from rotating when it’s moving towards a target.

Code:

public class StudentBehaviour : MonoBehaviour
{
    Rigidbody2D body;
    bool facingRight;
    SpriteRenderer sprite;

    public Transform target;
    NavMeshAgent agent;

    void Start()
    {
        body = GetComponent<Rigidbody2D>();
        sprite = GetComponent<SpriteRenderer>();

        agent = GetComponent<NavMeshAgent>();
        agent.updateRotation = false;
    }

    void Update()
    {
        agent.SetDestination(target.position);
    }
}

Solved it, just needed to add agent.updateAxis = false I hate life

1 Like