1
\$\begingroup\$

I have a game that I am trying to make. It is a twin-stick shooter that I want to design to have a LOT (Up to 500) of enemies on the screen. The game's base design comes from that of Geometry Wars, and serves as a learning experience.

A bit about my setup: i7 quad-core CPU @ 3.5GHz, 8GB of RAM, and Intel 4000 integrated graphics. While these aren't the best specs, they are now more and more common, so this is my target system.

There is an invisible plane that acts as the playing field. I built a NavigationMesh from this plane, and sample random points from that to spawn my enemies. The enemies use DetourCrowd to implement the flocking behavior. On my moderately-powerful machine, I can get around 150 enemies before I begin to experience drastic performance drops. Accounting for other potential issues, I made my enemies invisible, so only the agents are used, and still the performance drops significantly from 150-200 enemies on my machine. It is bad enough that this difference of 50 enemies drops my framerate from a solid 60 fps to <1 fps.

I decided to instead try using Bullet physics instead. I have the linear/angular factors setup to make Bullet act on a 2D plane. All of my enemies now use a Sphere for collision, have a mass of 1 unit, and no friction. They are not affected by gravity or external forces, but instead I set a fixed impulse at the beginning of each physics step. Additionally, the collision mask is setup so that the enemies only collide with each other. Around 350-400 enemies, I begin to see performance issues. They're not nearly as severe as the performance issues that I see with DetourCrowd, however they do come with an additional downside.

I use a small sphere set as a Trigger for firing off bullets. I handle the collision events to destroy the enemies. With the DetourCrowd method, this caused no noticeable performance drop. However with the Bullet approach, it causes a much more significant performance drop.

Overall, I can comfortably use ~120-150 enemies with the DetourCrowd approach, and ~200 enemies with the Bullet approach.

Are there any solutions that would give a much cheaper flock behavior for this game? I prefer solutions targeting 2D under the assumption that it will be cheaper than a solution targeting 3D.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Intel released an crowd collision avoidance algorithm and sample code a few years ago that's designed to solve this problem. It's parallelizable, and you may be able to adapt the algorithm to work with your entities.

\$\endgroup\$

You must log in to answer this question.