Hello there,
I’m really enjoying this fantastic A* tool so far, but I’ve run into a problem. Likely some beginner mistake on my end. I’ve got a dungeon that gets generated at runtime that I want to make a GridGraph for. It all works, except that the values I set for Obstacle Layer Mask and Height Mask seem to get ignored. Instead of what I want, I get a Mixed result with two layers: “TransparentFX” and “Layer3”.
My code looks like:
private void CreatePathfindingGrid()
{
// call this AFTER the 3d objects and everything have been generated. The pathfinding plugin
// will then create the pathfinding map.
AstarData data = AstarPath.active.data;
GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;
int width = mapSize;
int depth = mapSize;
float nodeSize = 1;
gg.center = new Vector3(0, 0, 0);
gg.SetDimensions(width, depth, nodeSize);
int obstaclesLayer = LayerMask.NameToLayer("Obstacles");
gg.collision.mask = obstaclesLayer;
int groundLayer = LayerMask.NameToLayer("Ground");
gg.collision.heightMask = groundLayer;
// make it half a node so that narrow corridors and things are walkable
gg.collision.height = 0.5f;
gg.collision.diameter = 0.5f;
AstarPath.active.Scan();
}
Which creates the grid just how I want it, but with the wrong layers. When I pause the game and check it in the inspector, the layers I specified aren’t set. What am I doing wrong? Pictures attached to explain better.