Best way to implement "RTS like" large number of entities using same model file

Hi I am new to Babylon (but not games dev) and thought I would plan a small project to encourage my learning of this impressive platform.

I want to create a pool of 200 agents, all sharing the same model, but moving, and coming into and out of existence separate entities.

The engineer in me feels it would be preferable to have a fixed memory pool of units, rather than create and destroy dynamically during gameplay.

I had thought of instancing the model, grouping them all in a container to aid scene loading management etc , but after reading this recent post about the challenges of switching an individual instance’s visibility I am less am unsure as to the best approach.

Any suggestion, or pitfalls learned from experience most welcome, for me and hopefully anyone else planning a similar project.

Welcome aboard!

I think VAT is what you want:

You can also search the forum for more references.

1 Like

What if the instances are slightly different, like the materials diffuse color is slighly different shade of blue?
Is this a big performance trade off?

thank you I will experiment with these tomorrow.

You can set an instance buffer with a different color for each instance, and use a material plugin to alter how the diffuse color is calculated.

Is there a better way to remove thin instances from the scene other then setting their co-ords way out of the view frustum?

You can copy the matrix of the last thin instance of the buffer over the thin instance you want to remove and decrement the thin instance count by one.