When we have many agents 50+ they start falling through the ground

I’m noticing a weird behavior in my project, everything runs fine until I have lots of agents, around 50, that’s when newly created agents, or some of the already created agents start falling through the ground, even if they are not moving at all, they would spawn and simply fall through the ground.

It’s as if there is some kind of hard limit on how many agents are supported? or could it be that some pathing calculation is taking too long (now that we have a lot of agents) and ending up being abandoned; which ends up causing the agents to just fall through the ground?

if you need information on my agents and their pathing components, it’s all here.

Does the FPS drop a lot as well?

Yea it does drop a lot. I haven’t looked at the numbers but we can notice a considerable drop.

It may be that if the fps goes low enough, the agents move forward enough in a single frame that at least half their body is below the terrain. If that happens, the agent will not be able to recover, and will fall.
You can mitigate this somewhat by ensuring that the agents are relatively tall.

I don’t think they move enough in one frame for half their body to be in the terrain. Also the terrain is flat.

This even happens to agents that simply spawn and don’t even move (and aren’t told to move either), like they spawn and just fall straight through the ground.

@aron_granberg This is still a problem :(, I tested a few things:

  • I’m able to consistently reproduce this, by spawning 24 agents at the same time, if I spawn 23 no problem, but 24 they spawn and about half of them drop through the ground a moment after they spawn (not immediately, about 1-2 seconds later). They are not told to move or anything, they simply spawn and that’s it.
  • There is a big FPS drop at the moment where the agents spawn, it only lasts for a moment and then it goes back to normal (above 30).
  • I disabled RVOController, RVOSimulator and RVODensity behavior, so the only A* components the agents have enabled are AIPath (2D, 3D) and a Seeker. (of course if I disable AIPath the problem goes away, but so does their ability to move).

I’m able to mitigate this spawning agents problem by increasing the space between them, so giving them extra space when spawning them.
If i don’t give them this extra space, i notice that right before they drop through the ground, they sorta bump into each other and turn a bit as if they’re trying to make more room for themselves.

There’s plenty of room around on the terrain, so it’s not like they ran out of room, and I don’t spawn them overlapping each other, I spawn them with a spacing of about 0.1 between them.

So for all intents and purposes the issue seems to be related to FPS drop, because even when I spawn 23 agents (the magic number from above) instead of 24, they don’t fall through the ground on spawn and they can move, but a bit later when action starts taking place and the FPS drops, some of them fall through the ground.

I can see that none of them are clipping through the terrain before they drop (also the terrain is flat), so it’s not like their bodies are halfway through the ground already before they fall.

We can take that simple scenario of just spawning 24 of them. The fact that at that moment of spawn, the FPS dips pretty hard and the agents bump into each other a bit causing a tiny movement/rotation, makes some of them fall through the ground (on a flat terrain) AFTER the FPS returned to normal; that FPS dip only lasts about 1 second or even less.

I’ll PM you a small clip of what’s happening.

That is very strange…

How tall are your agents? The yellow cylinder that the AIPath script draws. Is it reasonable?

The height is 2, it fits the agent’s model reasonably well.

I PMed you a clip, we can see the radius and height there when I enable gizmos.

any idea how I can debug this? I’m on the latest version of Unity by the way, 2022.2.8f.