University Tower Defence Game
The video above shows my object pooling script that I made a script that allowed me to easily pool and unpool objects by an id at a "reasonable" rate. This is an example code that is needed for generating:
GameObject isPooled = objectPooler.curObjectPooler.getObject(ID); GameObject curBullet = isPooled; if (!isObjectPooled) curBullet = Instantiate(PREFAB);
This is all stored in a data structure below. This makes it so that I can see if it is already in the array however allows the string key to be the same on multiple objects so that there can be more than one "bullets" id.
public List<KeyValuePair<string, GameObject>> objectPool;
While this solution worked there was a few problems, including the objects not resetting to default numbers meaning that enemies would spawn dead, and the wrong class. Which resulted in some interesting side effects. For Example:
This system however enabled me to be able to spawn mass amounts of enemies with little to no loss in fps a lot better than creating a new enemy everytime I needed it and was a great skill to learn. All bullets and enemies in the video below is using the object pooler system.