Support Forum

Raycast modifier only checks connections and not walkability. Intended?

Hello!

I need to use raycast modifiers (set to graph raycasting only) for my project.
I have a grid graph in the scene and some of my scripts change the walkability of certain graph nodes at runtime by setting the Walkable property to false.

What I noticed is that the modifier won’t work properly if I do this, as it just checks whether or not the nodes are connected, ignoring their walkability.
I might be missing something though: do I need to somehow update the graph after setting nodes to not walkable?

I am now solving the problem by setting the walkability to false AND also calling ClearConnections(true) on those nodes, but I might need to re-enable to walkability on certain nodes at a later point during the game, so I’m not sure if this is a good approach.

Thank you!

Hi

When modifying walkability on grid nodes you should also recalculate the relevant connections.

If you are only updating a single node, then calling

gridGraph.CalculateConnectionsForCellAndNeighbours(node)

is what you should use.

For more info see this part of the docs: https://arongranberg.com/astar/docs/graph-updates.php#direct

1 Like