Penalties with moving Astar grid moving not working

Hello,

This tool is really superb but I stumble against a problem.

I use the same setup as we can see in the procedural world example : a unit with a script (ProceduralGridMover.cs as in the example), that moves the Astar path grid at the unit’s position to search around. As in the example, the grid size is limited and smaller than the world.

I added a GraphUpdateScene.cs script to a new object a drew a shape to make a non walkable area (the field in the middle of the picture.

With a standard still grid that is not attached to the unit, all is good and we can see the non walkable area working.

But when I try with a grid that is moved to the unit position with a limited grid size, the non walkable area disappears.

It seems that it doesn’t like that fact that the grid is moving or that the grid intersects the area, but it’s crucial since the unit will move in large enthronement.

Maybe I miss something or an update method?

Thanks for help.

Hi

Yeah, since the GraphUpdateScene component only applies penalties to existing nodes, it will not work when the graph is moved. What you could do is to in the ProceduralGridMover script, make it so that when it does move it loops through all GraphUpdateScene components and calls the Apply method on them again. This will make them always valid, however it may have some performance impact.

Your graph has a really high resolution though, do you really need it to be that high? How large is your world? Are you sure it couldn’t be covered by a single graph?

Thank you for taking time to answer me. :slight_smile:
I will try to implement an update method for the GraphUpdateScenes that are close enough from my unit when graph is moving.

I’ll get back to you to let you know if this works the way I wanted. Also, I’ll try with fewer resolution.

By the way, my map is as large as the following picture (not my artwork by the way, it’s just for testing):

I’m intrigued by your question about using a single graph that covers all the map area.
Here are the feature of my game :
-Other maps in the game might be twice or third time this scale.
-There will be maps with different floors (layered grid).
-Update of the grid should be done “on the go” regularly by the fact that the player can trace a “magical bridge” over a river to let the unit cross it for example.
-I search a “1 for all” solution".
Knowing these prerequisites, do you think I should switch to an entire scan of the map instead of having a moving little part?

Many thanks.

Here are the news.

I try to launch the Apply method on GUS when the graph is moving.
No we can see that even if the entire shape is in the graph, it works.

Now, the problem is that it kind of replicate this shape to the every extremities of the grid when I move my unit.

I tried many things but I can’t get rid of this duplication.
How can I proceed?

Thanks for help.

Hi

Ah, that seems to be a bug.

If you open the ProceduralGridMover script I think you should be able to replace this line

graph.RecalculateCell(x, z, false, false);

with

graph.RecalculateCell(x, z, true, true);

and it should now clear those wrapped tags.

This now works well.:ok_hand:
Thank you, you’re my hero!

1 Like