Can I instantly get the number of characters around a character?

Hello, I want to process a character according to the number of characters around it. Can I reach the number of characters?

You can get the number of characters the local avoidance system took into account using:

rvoController.rvoAgent.NeighbourCount

I am using the follow entity component, is there any for that?

Hmmm. I think this should work. Let me know:

var agentIndex = World.DefaultGameObjectInjectionWorld.EntityManager.GetComponent<AgentIndex>(followerEntity.entity);

var simulator = RVOSimulator.active.GetSimulator();
var numNeighbours = simulator.outputData.numNeighbours[agentIndex.Index];

It worked and thanks for the quick reply.

1 Like

Hello Aron, Well, let’s say there are 5 people from team A and 1 person from team B. 6 people are shown around the characters in team A, so how can the characters in team A ignore each other?

I’m not quite sure what you mean?

How can I distinguish between enemy characters and friendly characters? This code gives the total of all characters. What I want is to distinguish teammates among themselves.

There’s no way to do that using this method, I’m afraid.
But if you only have 10 or so people on each team, you could just do something brute force.

It is possible to query the internal quadtree directly using SimulatorBurst - A* Pathfinding Project, but this is not very well documented.

So can I access the getcomponent of the characters around the character?

Technically, yes. But it will be through a VERY roundabout process, and not very efficient.

If you need that, then I think you are better off with a custom proximity detection setup. There are many packages on the asset store for this exact purpose, I believe. But as I mentioned before, if you only have a few agents, doing it naively is totally fine.

Yes, I don’t have many representatives. Can you write the sample code?