antfarmar / Unity-3D-Asteroids

A simple Asteroids clone. In 3D.
The Unlicense
65 stars 15 forks source link

TODO: Object Pooling #2

Closed antfarmar closed 8 years ago

antfarmar commented 8 years ago

Implement a simple object pooling script for asteroid and bullet reuse, instead of constantly instantiating and destroying them (inefficient, alot of expensive gc calls).

See: http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/object-pooling http://answers.unity3d.com/questions/765574/can-someone-just-post-a-generic-object-pool-script.html https://theliquidfire.wordpress.com/2015/07/06/object-pooling/ (Good read!)

antfarmar commented 8 years ago

Implemented with a reusable ObjectPooler static singleton class. Uses a Queue to pool Poolable type objects. Manages multiple pools per GameObject type using a Dictionary.(string key).

See the wiki entry about Pooling.

antfarmar commented 8 years ago

Currently uses a List<> implemented as a Stack: O(1) complexity when removing/adding to it's end.