Having trouble with GraphUpdateShape

I’m using a recast graph and I’m trying to get all of the nodes under a long, thin wall/box so I can adjust penalties. The wall/box for example could be 2cm wide but several meters in length.

I’ve successfully used a GraphUpdateObject using the bounds of the box, but the problem is it’s not accurate enough for my needs. Most of the time, the box is on a 45 degree angle to the world and on a long thin wall on a 45 degree angle, it collects far too many nodes due to bounds facing world-axis.

Here’s a chunk of some of the code I’m using:

GraphUpdateObject guo = new GraphUpdateObject(bounds);
guo.updatePhysics = false;
guo.addPenalty = penalty;

graphUpdateShape = new GraphUpdateShape(_bottomVerts, true, transform.localToWorldMatrix, 10f);
guo.shape = graphUpdateShape;


_bottomVerts is a Vector3[4] that is the positions of the bottom 4 verts of the wall/box in world space (the mesh is procedurally generated). I’m not sure if I’m using the Matrix4x4 correctly in the GraphUpdateShape constructor, that was a bit of a guess on my part. From what I can tell, no nodes are being updated when I use this.


If it’s just 2cm wide then there is a big chance it will not actually contain any nodes. The GraphUpdateShape operates on the centers of the nodes, not on the whole node shape. I would suggest that you make the box a bit thicker until you get the desired number of nodes to be inside of it.

Thanks for the reply Aron.

I tried making the shape much wider/larger and still am not able to get any nodes to update. Here’s a screenshot that explains exactly what I have going on here. The red lines are Debug.DrawLine’s from each vert in my shape and the blue lines are the same to showcase my bounding box. Normally the shape is above the graph/floor by about 0.2 units but I’ve lowered it to be below the floor by 0.5 units here. I’ve tried raising and lowering some of the shape verts in Y space so that it would encompass the nodes in the Y axis as well but that didn’t seem to work either.

The goal I’m trying to achieve is that the player can put up these energy walls to build bases. The NPCs should rather go around them if possible, but if an area has been completely blocked off or if the penalties make sense, they can path through the wall which they would then attack the wall to break it which would remove the penalty.

At first I was using NavMesh cutters on the wall which worked well, but that created the issue of the NPCs not being able to path to the player at all if they had fully enclosed themselves. The NPC would then not know that they would have to break the walls in order to get to the player.


Ah. I see.
Well there is actually a nice solution for this when using a recast graph.
On the NavmeshCut object there is an option called ‘isDual’. This will preserve the inside of the cut and then you can use a graph update object to mark those nodes as having a high penalty.

I’m not sure why it didn’t work previously though. Have you tried using a GraphUpdateScene component and mark the points manually (see https://www.arongranberg.com/astar/documentation/dev_4_1_8_94c97625/graphupdatescene.html).

Regarding the Y axis you mentioned. You need to make sure the bounding box encloses the nodes along all axes. The vertices’ Y coordinates are essentially ignored.

Thanks for the suggestion! I ended up trying out GraphUpdateScene and was able to get that working perfectly. Not sure what I was doing that it didn’t like, but this seems to work :slight_smile: Cheers!

1 Like