Author Topic: Pooling objects in a scene.  (Read 72 times)


  • Junior Playmaker
  • **
  • Posts: 64
    • View Profile
Pooling objects in a scene.
« on: August 01, 2020, 02:01:14 AM »
Hi again,

So, i was wondering about pooling and performance etc.
I understand pooling as a concept, and have set up pools for lasers, enemies and hit markers etc, you know, all this little things that are typically rapidly created/destroyed.

But what about other stuff? Like, scenic objects that in the scene?

For example...

In my simple spaceship sideways scroller arcade shooter i have a fairly large playing area, with various things spread around:

A mothership very high up in space following a path.

Some asteroids whizzing around.

At ground level i have some comets whizzing along, just above the ground, with particles etc.

And all the rocks, low poly meshes that make up the landscape.

Basically, everything that makes up the level/scene.

When I'm play testing the game in the editor, in the scene window i can see that everything is being processed; mothership moving, comets whizzing, asteroids floating etc etc, but in the game window i might just have my little fighter ship slowly floating in empty space, with a nice star filled background.

To maximize performance, should i pool all the other stuff and only have it come 'alive' when the little fighter ship is nearby?

Like, in the game, are processor resources being wasted calculating things that that aren't on the screen?

Does this make sense?


  • Administrator
  • Hero Member
  • *****
  • Posts: 5187
    • View Profile
    • jinxtergames
Re: Pooling objects in a scene.
« Reply #1 on: August 02, 2020, 12:14:45 AM »
If for example the floating objects are moving or rotating.
That will be done, even off screen.

depending on the re-usability you can do different things.

For example, the asteroids could be pooled, as you probably can use it in several places (and you can set some randomness on them to have for example different sizes)

Things that are not used a lot but do have particles and / or movement you could disable/enable by checking the distance.
You can set groups by parenting or use arrays.
So that you would need only 1 get distance and compare, for a certain group of items and not for every object.

if you have certain objects that are moving in a certain direction.
You could have a parent (or empty object) that does the movement and the mesh/particles etc as a child or separate object.

This way you could disable the child/separate object when far away but still move the object.
For parent you can just disable the children for separate it can also enable/disable the object, but you need to add a get/set position to follow the empty object.