Grid Graph and size of node

Currently working on a grid based game a la Two Point Hospital, where walls are at the edge of each cell instead of directly on a whole cell.

Testing out the Grid Graph:

With a node size of 1 and an offset of 0.5 for the whole grid, I can have my character going through the pathway, but not in between these two walls.

At a node size of 0.5 still the same issue (picture below)

Now at a node size of 0.25 it works

at such small value for node size, in larger map it seems like it would not be very efficient as the number of nodes are quadruple. For a simple map of 50x50 of my tiles, it ends up with a 200x200 of nodes for the graph.

Should I be doing this differently? Should I prevent the construction of two walls separated by only one tile in my game?

Hi

The grid graph works by defining walkable and unwalkable nodes. The connections are calculated based on that. So a wall necessarily needs to take up one row of nodes.

It is possible to use some custom code to run checks for each connection and get what you want. But it requires some code and will also slow the scan down (as it needs to run physics 8 checks per node instead of just 1).

In that case, I will just run with that (0.25 node size) and see later on where I should have limitations. Optimize only when necessary after all :wink:

Thanks

1 Like