A* Pathfinding Project

NavMesh Cut moving entire navmesh bounds


#1

I have a navmesh which is generated with local coordinates in the vertices that correspond to it’s world position. This is because I have a single instance of Astar Path in the scene sitting at (0,0,0). My navmeshes are all saved as .bytes files in the resources folder.

At runtime, I’m loading and unloading the navmeshes dynamically depending on where the player is in the world. My code for loading the .bytes files is as follows:

	private IEnumerator LoadNavmesh(string path)
	{
		ResourceRequest resourceLoadRequest = Resources.LoadAsync(path);
		yield return resourceLoadRequest; // wait until ready
		var textAsset = (TextAsset)resourceLoadRequest.asset;
		if (textAsset != null)
		{
			AstarPath.active.data.DeserializeGraphsAdditive(textAsset.bytes); // appends to graphs 
		}
		else if(Application.isEditor)
		{
			Debug.LogFormat("Failed to load navmesh asset from the path '{0}'", path);
		}
	}

This all works wonderfully, however, I need to incorporate navmesh cutting for destructible gameobjects which should only block enemy movement until the player or enemy breaks them, for example, barrels. Upon adding a single instance of the NavmeshCut script to one of my barrels and running the game, my navmesh suddenly shifts it’s entire bounds to fit the white bounds defined by the AStar Path script.

Here is an example of the difference between the way my navmesh appears with and without the navmesh cut script on a single object.

So it appears that something in the NavmeshCut script is re-centering the navmesh to fix the current center of the AStar Path instance. Is this a bug in the framework or am I missing something?

Thanks in advance.