Thanks for the information
I tested out method 1 out of simplicity. I put the NavmeshCut for every collider of the wall due to not being sure where a wall will meet the navmesh.
I have put all the components on a single gameObject.
I made a few tests: You can imagine that those walls I’m creating can end up having lots of colliders because each box collider occupies only 1x1x1 unit.
Using Unity’s native NavMesh system I was forced to create new gameobjects for the NavMeshObstacles.
With your system it appears I can stay on gameObject and put all the components there.
Compared to Unity’s NavMeshObstacle the performance is significantly worse.
However if I could somehow give the NavmeshCut knowledge of when to update I think it would make a big difference instead of updating based on a frequency.
===> How can I achieve this?
I simply want to turn on/off the cutting.
Everything worked fine on a most walls but some cause errors to pop up. I made a test with and without creating new gameobjects to put the component on but the error pops up just the same, it’s not related.
This error pops up depending on what type of walls I built. I’m not sure yet what the reason for this is.
Too many perturbations aborting.
This may cause a tile in the navmesh to become empty. Try to see see if any of your NavmeshCut or NavmeshAdd components use invalid custom meshes.
UnityEngine.Debug:LogError(Object)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:420)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.TileHandler:CutPoly(Int3[], Int32[], Int3[], GraphTransform, IntRect, CutMode, Int32) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:682)
Pathfinding.Util.<>c__DisplayClass41_0:<LoadTile>b__0(IWorkItemContext, Boolean) (at Assets/ASSET STORE/AstarPathfindingProject/Generators/Utilities/TileHandler.cs:1188)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean) (at Assets/ASSET STORE/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:299)
AstarPath:PerformBlockingActions(Boolean) (at Assets/ASSET STORE/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath:Update() (at Assets/ASSET STORE/AstarPathfindingProject/Core/AstarPath.cs:864)
Here is how I build the NavmeshCut on new gameobjects. I find it weird that this could cause any errors seeing as they’re just the same measurements as the BoxCollider.
private NavmeshCut CreateNavmeshCut(BoxCollider _box, string _index)
{
var newGo = new GameObject($"NavMeshCut {_index}");
newGo.transform.SetParent(this.transform);
newGo.transform.localPosition = Vector3.zero;
newGo.transform.localRotation = Quaternion.identity;
// var newGo = this.gameObject;
var obstacle = newGo.AddComponent<NavmeshCut>();
obstacle.type = NavmeshCut.MeshType.Rectangle;
obstacle.center = _box.center;
obstacle.height = _box.size.y;
obstacle.rectangleSize = new Vector2(_box.size.x, _box.size.z);
obstacle.useRotationAndScale = true;
return obstacle;
}