2D Grid Graph generator

I need to create a generator, which creates new grid graphs. Everything works, but I cannot change the grid graph to 2D (Like “Use 2D Physics” and “2D”).

I just don’t know what methode I need to call. I looked at the documentation, but didn’t find anything.

This is my code.

// This holds all graph data
AstarData data = AstarPath.active.data;

// This creates a Grid Graph
GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;

// Setup a grid graph with some values
int width = 10;
int depth = 10;
float nodeSize = 0.75f;

gg.center = new Vector3(posX * offset.x, -posY * offset.y, 0);

// Updates internal size from the above values
gg.SetDimensions(width, depth, nodeSize);
// Scans all graphs


Those are controlled by GridGraph.is2D and GridGraph.collision.use2D respectively.

1 Like

GridGraph.is2D is not working.
‘GridGraph’ does not contain a definition for ‘is2D’ and no accessible extension method ‘is2D’ accepting a first argument of type ‘GridGraph’ could be found (are you missing a using directive or an assembly reference?)

GridGraph.collision.use2D does work.

Now I just need to define what kind of Obstacle Layer Mask i want. What variable is this?


Which version are you using?

GridGraph.is2D was only introduced in the latest version.


1 Like

Just as I wanted to look the version up and I got a pop up which informed me, that theres a new version from the pathfinder up. Downloaded it and now it works.

Thank you a lot!
Best wishes

1 Like