Zombie Runner Enemy Pathfinding Optimization

Not sure if covered later in the course but I kept getting so annoyed that the enemy would just stop if I went to an “unreachable” location within the NavMesh. This little trick optimized it and made the enemy more “zombie like”

Before:

navMeshAgent.SetDestination(target.position);

After:

        NavMeshPath nextPath = new NavMeshPath();
        if(navMeshAgent.CalculatePath(target.position, nextPath)){
            navMeshAgent.path = nextPath;
        }
1 Like

Privacy & Terms