Improving performance with Object Pooling

One of the things that most impact the performance of our games is cloning new objects. If you only need to clone a few objects, you won’t have a problem; however, if you need to clone many objects(bullets for example), then the performance of your game might start to slow down. The solution to this is to use object pooling.

The idea is to reuse objects instead of cloning and destroying them every time.

This example shows how I implemented this technique in Ready: https://ready.app.link/5h7O6Ml5EL

We start the scene with the number of objects that we will need already created and in a line, the pool. When we need to “spawn” the object, we move the first object of the line to the desired position and later on, instead of destroying the object, we move it back to the end of the line. Every time we “spawn” an object we also need to update the position of the objects in the line by just moving them forward. It is important to notice that we need to “disable” the objects while they are in the pool so that they don’t move around and ruin the line since everything is based on their positions.

Of course, this won’t be possible to use in every game, but I hope it might be useful for some people.

Here are two more in-depth explanations of object pooling:

They explain things that are more focused on Unity and programming, but we can learn things that we can also apply to Ready.

Please let me know if you have any suggestions on how to make this even better! :grin:

4 Likes

Thanks @victoroda :+1:, it’s a really good decision in many situations