Stop when destination is crowded

Hello,

I have seen the functionality “Stop when destination is crowded” in the beta but can you suggest a method to check if destination is crowded instead of automatically stopping and return true/false?

Thanks

Hi

What that functionality is built on is a function to check what the agent density is in a particular region.
You can check that using this code:

var radius = 5.0f;
var area = (Pathfinding.RVO.RVOSimulator.active.GetSimulator() as Pathfinding.RVO.SimulatorBurst).quadtree.QueryArea(transform.position, radius);
var density = area / (radius*radius*Mathf.PI);

This method is also safe to run from within a burst job.

1 Like

I will give it a go thanks!

Hey Aron, I had a similar solution using SphereColliders to check if an x amount of enemies are there aka crowded which is very similar to your solution albeit yours is multithreaded which is great. One issue that our designers have picked up is in narrow spaces or when the player has his back against a wall, neither solutions understand that so density and amount is never correct. Is there a way that your area is in relation to the graph’sposition? Since it would never calculate behind the wall if there was no graph there instead of a solid radius.

Hi

Sorry, that is not possible at the moment. You could possibly do an approximation by getting the nearest node and then doing a small BFS search to find the nearby nodes (see https://arongranberg.com/astar/docs/pathutilities.html#BFS).