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.
- 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
- Object : Get Object from pool