NavMeshAgent rotation

In my project I use 2D-Sprite (on a plane) that uses a NavAgent to navigate. Since I use a plane, I do not want the NavMesh to change the gameObjects rotation. However, I still want to get the rotation the NavMesh would theoretically assign, to determine which Animation to use. Does anyone know, how to get this rotation?

if you want to stop rotation use the updateRotation field of the NavMeshAgent class

// Drag & Drop your navmesh agent from the inspector
var Nav : NavMeshAgent;

function Update()
{
      Nav.destination = target.position;

      //This line will stop the rotation of your navmesh
      Nav.updateRotation = false;
}

If everyone needs it, you can calculate the desired direction.
This snippet calculates the angle between 0 and 360:

    NavMeshAgent agent = GetComponent<NavMeshAgent>();

    float angle = Vector3.Angle(agent.velocity.normalized, this.transform.forward);
    if (agent.velocity.normalized.x < this.transform.forward.x)
    {
        angle *= -1;
    }
    angle = (angle + 180.0f) % 360.0f;

You may need to adjust some values, depending one the axes you’re using. (In my case, left/right was determined by the x-value)