- Home /
Navigation Mesh not working in build
I've been working on a project for over a year now which involves AI guards that can patrol, chase the player, etc. These guards use a baked Navigation Mesh to calculate their ideal path, the guards do not implement a Nav Mesh Agent component, I am simply calling NavMesh.CalculatePath() and moving the guards manually.
This has worked perfectly until a couple weeks ago when I noticed that the guards act as if there is no nav mesh when the game is played in build. That is to say, the AI can still be triggered, but they are unable to move as their movement relies on path-finding. The guards still function perfectly in editor, the problem only arises in build.
I'm almost certain the problem has nothing to do with my own code (yes, I'm that guy) but here's a snippet anyway.
public void pathTowards(Vector3 target, float slowRadius)
{
NavMesh.CalculatePath(form.position, target, NavMesh.AllAreas, navPath);
if (navPath.corners.Length > 0)
pathActive = navPath.corners[0];
else
pathActive = form.position;
pathTarget = target;
pathIndex = 0;
if (Vector3.Distance(form.position, pathActive) < 0.2f)
{
pathIndex += 1;
if (pathIndex < navPath.corners.Length)
{
pathActive = navPath.corners[pathIndex];
}
}
moveTowards(pathActive);
rotateTo(pathActive, 5f);
}
I gave the problem a bit of a google and couldn't find a fix. If anyone can be of any help, I would be eternally grateful. We are meant to be testing the game for feedback tomorrow, it would be a massive shame if our testers had to play the game in editor.