Large scale battles?

Hi.

Now the newest pathfinding project will have a good anc cheap rvo in it. This gives us a good way to avoid many agents and not to run trough each other. So this got me thinking. In order to create a large scale battle scenario one would have to find a cheap way to tell a specific agent a target where enemy npc is located and attack it. In theory it should find the closest target.

The usual suggestion would be to have a raycast or sphere collider to measure against all anemies and create a waypoint to the closest one. Unfortunately this option would not scale very well because colliders are expensice and for every agent run trough to find the enemy will kill the performance.

Since the RVO demo worked so well i was wondering if there is another and cheaper way to find the enemy. Rvo does have an algorithm avoiding its neighbours and thus creating the chain reaction between each other. Would it be possible in theory to turn it other way around. Instead of avoiding the nearest neighbour we can just sample it and if its an emey then we will engage it in some way. But if its just an agent on my own side then i will just avoid it.

Any thoughts?

Thanks.

The RVO scripts use a KDTree (http://en.wikipedia.org/wiki/Kd-tree) to efficiently find all close agents, it is really fast. You can find a bunch of tutorials on the web about how to implement it.
I have exposed the KDTree in the implementation because I don’t want to be too restrictive when it can be useful. So you should be able to query it for agents and then use a Dictionary<Agent,YourUnitClass> or similar to map the agents to the real classes to see if it is an enemy or not. I will not modify the RVO code for special behaviors such as attacking a unit instead of avoiding it, however I might implement layers in the future. They would work similar to physics layers so that an agent can specify which groups of agents it should avoid and which it should just ignore. This could be used to make units not avoid enemy agents… but of course that raises the problem that they might then collide and it might not look good (depending on the game of course).