Setting up grid graph questions

Hi, I’ve just started to set up the grid graph for my game (A* Pro version, 320 x 320 nodes) and have a few general questions:

  1. The graph gets scanned from code and when it does, I get a log entry such as ‘Process took 1405 ms to complete’. However, on start-up I also get such a message (with a shorter ms value) even though the graph isn’t being scanned then. Is this normal behaviour?

  2. I was able to exclude non-traversable mountain tops in my terrain from the graph by setting the ‘Height testing - Ray length’ value. Is there a similar value I could use to exclude non-traversable bodies of water, e.g. anything below a certain depth? At the moment I’m using an invisible obstacle cube that intersects with my terrain. It works, but seems crude. Is there a better solution? Something like a bounding box maybe for grid graphs?

  3. I have set ‘Connections’ to eight, however it does not work in some cases. I hope the below images illustrate my problem. Is there a setting I might have missed?

No connection is being made diagonally:

Thanks for your time and a great asset!

  1. Im unsure why this would be the case, @aron_granberg might be able to answer this
  2. You probably want to have a look at the GraphUpdateScene component for that.
  3. This looks like it might have something to do with your maxStepHeight setting. Im not sure here.

Thank you for your reply.

  1. That seems even more work than just a simple box. I was hoping for a single parameter, like the one used in ‘Ray length’.

  2. There is almost no height differential between both squares, so I dare say the maxStepHeight isn’t going to fix that.

  1. The graph is usually scanned when the game starts. You can control if it is using the A* inspector -> Settings -> Scan On Awake. You can also use cached startup to avoid it (see
    Normally the first scan takes a lot longer because the C# code needs to be JITed. Therefore subsequent scans normally take significantly less time.

  2. An invisible obstacle cube is usually the best option.
    You can use a custom script which sets walkability based on the y coordinate, but it’s usually simpler to just use a collider.

  3. Diagonal connections require at least one axis aligned connection in the same direction (± 45 degrees). In this case I would recommend a higher resolution of your grid graph, however if necessary I can show you the part of the code you need to modify to change this default behavior.

Thanks Aron, that helps a lot. I prefer to keep the graph resolution 1:1 with my terrain grid, so if you could point me to the part of the code I need to modify to get the diagonal issue sorted, that would be great.

In the GridGenerator.cs script -> CalculateConnections method you need to replace this code

// Loop through axis aligned neighbours (down, right, up, left) or (-Z, +X, +Z, -X)
for (int i = 0; i < 4; i++) {


// Loop through all neighbours
for (int i = 0; i < 8; i++) {

Thank you once again, that worked great!

1 Like