Diagonal connections in a simple Grid Graph

My 8 direction grid graph is missing a diagonal connection (the green line drawn into the screenshot below).

It seems as if a node doesn’t actually check its 8 neighbour nodes, but rather checks its 4 neighbour nodes (up,down,left,right) and then creates diagonal connections in between nodes that are joined by a vertical and a horizontal connection. How can I make my graph find its missing diagonal connection?

I think I might have misunderstood something very basic here, any help is much appreciated :slight_smile:

Hi

Usually those connections are disabled because units will get stuck there if one would use some kind of physics engine.
This is the usual behavior when generating graphs in most pathfinding systems. You can disable this behavior by opening the GridGenerator.cs file, find the CalculateConnections method and change the IF statement that reads

if (((conns >> i | conns >> (i+1) | conns >> (i+1-4)) & 1) != 0) {

to

if (true) {

or simply remove the IF statement.

Works perfectly!

I assumed my diagonal connections were allowed by default, but I agree that behaviour might not be well suited for realistic simulations, in contrast to traditional board games (i.e. bishop-style movement).

Thanks a lot for the help! Great to see you keep improving this awesome library.

1 Like