Object pooling node

To save performance, object pooling is a very common practice, this removes the need to create and destroy objects because this costs more resources.
It’s commonly used to spawn and unspawn enemies or projectiles.
This is a node logic i’ll try to make.

Functions :

  • CreatePool( size, object) , called the first time the logic node is called
  • SpawnOneObject() , returns false if no object available
  • UnSpawnObject(object) , removes object from scene and put it back on pool array

Input nodes and fields :

  • int : Pool Size
  • Object : Object to pool
  • Object : Put Object on pool

Output nodes

  • Object : Get Object from pool

That’s a good idea. An example that might help for designing the ObjectPool in Haxe:

1 Like

The Array will be initialized with the fixed size you put when you use the node, so i don’t have to make it complex with resizing.
Well … it will be free for anyone to use, so anyone can improve it or add functionality as needed.

1 Like