1
\$\begingroup\$

I'm prototyping a 2.5D style game. I have my sprites angled at a 33° angle on the x axis.

I'm using the NavMeshAgent for basic navigation and pathfinding. I've set the Angular Speed to 0, to prevent the auto rotation to the destination.

But the x rotation is always reset to 0 on play. Is there a setting I'm missing, or do I need to set the rotation in script?

enter image description here

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

You probably need to set navmeshAgent.updateRotation = false in a script. See updateRotation.

\$\endgroup\$
1
\$\begingroup\$

Adding this Code worked for me.

private void Start()
{
    // Store the initial rotation
    initialRotation = transform.rotation;
    
    // Get the NavMeshAgent component
    navMeshAgent = GetComponent<NavMeshAgent>();
}

private void Update()
{
    if (navMeshAgent.velocity != Vector3.zero)
    {
        // Apply the initial rotation
        transform.rotation = initialRotation;
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .