How should I manage large number of object on mobile

What I need:

  • A lot of independent bullets
  • Run on mobile

What I’m doing:

  • Bullet are gameobjects(pooled).
  • Each bullet has no component other than Transform.
  • Control all bullet from one script => mediocre performance :expressionless:

What I’m tried:

  • Use struct to store bullet state. Graphics.DrawMesh to display

  • Fast.

  • Bullet meshes can’t be batched => thousands of draw calls => Can’t use on mobile :frowning:

  • Like above. But use instanced material to draw bullets

  • Faster.

  • But ~60% mobile don’t support GPU instancing :frowning:

  • Like 1st. But combine all bullet into one mesh on-the-fly, then DrawMesh only once

  • Only 1 draw call

  • Too high CPU usage :frowning:

How can I improve the above strategies? What are others options?

I abused a ParticleSystem to draw “many of the same things” with one draw-call on mobile.

I used a ParticleSystem simply to render a whole lot of objects at specified positions from game-code. The particle system itself wasn’t emitting any particles.

The idea is to use an Particle[ ] array, update the array with (bullet) positions from your game-code when needed and assign it using ParticleSystem.SetParticles.

This allowed me to render many objects with custom positions (and other attributes such as Color) with one draw-call only.

Not sure if it’s faster than what you already tried though.

1 Like

@Le_Tai any improvements? advices? especially mobile?

¯_(ツ)_/¯

Make do with less is what I did. Maybe GPU instancing is better supported after 3 years?