Hi, first of all… is this plugin still supported? What has happened, I see no more posts… is there a new forum or something?
But, if there is someone still reading… I’d like to know how I can connect 2+ grid graphs together, and if I can disable them at runtime.
Thanks,
Cya
Um… I am not sure why you cannot see any posts…
There are several posts from within the last day.
Generally I really recommend against linking together multiple grid graphs, you often end up with nasty issues when characters cross the border between the graphs. Pathfinding itself is fine, but characters can get confused. Usually it is just better to have one large grid graph.
There was previously an experimental feature which could link together nearby graphs, but I removed it for this very reason (and it was never actually exposed in the interface).
Thats strange… but anyway, I’m glad to see you are still around, would be a real shame to see such a good plugin be forgotten.
I see. Just so you understand why I’m asking this. I got a level which is basically a crossroads, with an “arena” in the center and 3 roads in opposite directions. I need pathfinding on everything, but to fully cover the roads, I will need a hugeeeee grid graph, and once the player leaves the road I really don’t need the pathfinding there anymore… also it generates thousands of “unwalkable” nodes in the middle of nowhere, I know that the weight of this is probably almost 0, but I suppose that looking through such a huge graph is not really ultra fast (and its a mobile game).
So I though it would be possible to create at least 4 grids, 1 for each road and 1 for the arena, and once the units left one of the grids, they just looked in the other one, so there would be thousands less nodes, and I suppose iterating through them would be faster.
Is there an alternative for this scenario or should I just use a huge grid graph and thats it?
Thanks for the prompt response,
Best regards,
Allan
Hi
Sorry for the late answer.
I can see that that in that specific case it would be useful.
I would recommend that you use a recast graph instead if you can, that will only use memory for the parts that are actually used and is generally a better fit for larger areas.
The huge grid graph would use a lot of memory (which might be a problem on mobile), but it wouldn’t slow pathfinding down much I think since the pathfinding search only looks at the nodes which are walkable.
Hi,
I see. I followed your advise and changed to recast graph, however on the sides of the road I have giant colliders that stop the player from leaving the playable area, and regardless of what I do, the Recast Graph keeps creating graphs over the colliders… is there a way to prevent it? I tried making the colliders have 100000000 height, and lowering the recast graph area as much as I could… made no difference at all…
This is also creating a problem for us… we are making a targeted skill that should get the nearest walkable node, and that works perfectly, however it is getting the nearest node from other graphs that is not the graph the unit is currently in… we are using the following:
AstarPath.active.GetNearest(TargetPosition, new NNConstraint {constrainWalkability = true}).clampedPosition;
But apparently getting the wrong graph… is there a way to get the graph that is currently used by the unit?
The first answer would also solve the second answer I suppose, but, if its not possible there you have it.
Thanks for your attention,
Best regards,
Allan
Hi
To cut away a piece of the graph, you will need to use a NavmeshCut.
Or you can just make sure that there is no ground there that the graph sees (that will be simpler).
PS: When you add a navmesh cut, make sure you also add a TileUpdateHelper component somewhere in the scene (just one)).
You can also get the nearest node which the unit is in.
// Get the area which the unit is in var area = GetNearest(unitPosition, NNConstraint.Default).node.area; // Find the closest node in that area GetNearest (targetPosition, new NNConstraint {constrainWalkability = true; constrainArea = true; area = area});
I see… well, I will have to place my circles to avoid it creating other graphs lol, but alright.
About the code example, GetNearest is in what “using”? The only place we found this method is in AstarPath.active.GetNearest… in which case it is getting the wrong graph to find the nearest…
should have been AstarPath.active.GetNearest.
Could you show a screenshot of it finding the wrong graph component?