So there’s a chance you might be getting this error now depending on what you did earlier in the course.
We’re now calling Cancel on the mover script from within the fighter script. If the enemy dies, it will trigger the CancelCurrentAction() code which will eventually call Cancel on Mover. All well and good unless you happened to disable the enemy navMeshAgent on death BEFORE calling CancelCurrentAction().
It was disconcerting to see this all of a sudden but fortunately the fix is very simple. Just disable the navmesh agent after you call CancelCurrentAction(). Here’s what my code looks like.
private void Die()
{
isDead = true;
GetComponent<Animator>().SetTrigger("die");
GetComponent<ActionScheduler>().CancelCurrentAction();
if (TryGetComponent<Collider>(out Collider collider))
{
collider.enabled = false;
}
if (TryGetComponent<NavMeshAgent>(out NavMeshAgent navMeshAgent))
{
navMeshAgent.enabled = false;
}
}