I’m trying to make my characters avoid each other and the local avoidance does not suit me, I talk about 10 characters aiming to different points around a moving target.
I’d better see them disabling the nodes they are on while moving, like that the calculated paths take in account these obstacles from the start.
But if I do that the paths go crazy because the start nodes are disabled.
I am pretty sure I don’t see the thing like I should, is there a way to solve that?
Maybe I could add some penalty to the nodes the characters are standing on but how can I restore them once they are empty?
There’s also an old beta of the cooperative pathfinding available here https://www.arongranberg.com/astar/download if you click on ‘Show Older Versions’ and choose the one labeled ‘cooperative’.
The Agent group manager ranks the agents based on distance to the player, and allows the closest one to calculate it’s path first. ( I used BlockUntilCalculated to make sure others don’t calculate their path yet before this one finishes ). Once it’s path has been calculated I add a the current position and a few nodes infront to the blocked list. Then proceed to the next agent.
The ITraversable will block the path finding for other agents on those nodes.
You might still have to alter the GetNearest function to find a new target destination in case an agent is trying to use a blocked node as a destination.
For this you’ll have to work with the NNConstraint You’ll have to make some tweaks to feed the data from the ITraversableProvider into the NNConstraint but it gives great results in tight situations.
Below you can find a screenshot of my implementation. The thin vertical line is the result destination, even though both were fed the position of the capsule.
This solution is definitely not the best one, you loose a lot of the multi threading performance etc. But you could manually offset path calculations per agent etc. This solution definitely worked for us.
If you have further questions feel free to reach out.
-Wolf
If you want I can share some code snippets of how it works on my end.
Though it has been a while since I’ve implemented this, so I’d have to look into the details and make sure I don’t leave out any important steps
Hi, Im trying to implement something similar now and I want to ask whether I can see some code snippet? I would be really grateful since I struggle with this for weeks