Different element sizes in the grid

Hello @aron_granberg I have been using the grid graph for a while now in our project and I reached the point of differently sized obstacles or agents that can move and open up paths.

About obstacles, I want to make them destructible and open up paths as we go, similar to the doors you have in your example but my current implementation is the following:

GraphNode node = AstarPath.active.GetNearest( transform.position, BlockedConstraint.Blocked ).node;
transform.position = ( Vector3 )node.position;
Block( node ); // this calls the InternalBlock of the BlockManager

Should I grab the collider’s bounds’ GetNearest and try to see what is it blocking at the edges and block everything inbetween as well? Sounds too unoptimised.

I read this post here: Grid graph movement for units with different size - #23 by Akkerman which somewhat talks about square agents and their traversal but for obstacles they can be different shapes.

Hi

Do you need these obstacles to have different traversability by different agents?
If not, you should probably not be using a BlockManager to handle them. Use regular graph updates instead. See Graph Updates - A* Pathfinding Project

As long as I block and unblock the nodes below them then no. Are you suggesting I rescan part of the map?

Bounds bounds = GetComponent().bounds;

AstarPath.active

Returns the active AstarPath object in the scene.

.UpdateGraphs

Update all graphs within bounds after delay seconds.

(bounds);

Yes, that’s what I’m suggesting.

so I guess their layer should be one that blocks the original grid so that the grid gets generated properly and then I just use the collision’s shape to put it back in?

1 Like

hmm I tried it and the problem straight away is that if I do it this way then they aren’t part of the grid anymore:

image

so I can’t use the grid to select them and eventually destroy them

I could shoot a ray from each node to see if it’s colliding unless you have any better ways @aron_granberg