NullReferenceException: Object reference not set to an instance of an object

RPG.Movement.Mover.Update () (at Assets/Scripts/Movement/Mover.cs:23)

Getting this after adding the line: navMeshAgent.enabled = !health.IsDead(); and animations break.

If I comment it out, then the game is back to working except the navMesh not disabling. What elese should I check?

Have you assigned the navMeshAgent and health?

Probably something like this in Awake()

void Awake()
{
    navMeshAgent = GetComponent<NavMeshAgent>();
    health = GetComponent<Health>();
}

I don’t know how I missed that, thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms