video thumbnail 20:56
[Unity 5] Object Pooling Tutorial

2016-01-11

[public] 56.4K views, 1.21K likes, 7.00 dislikes audio only

Object pooling is an optimisation technique which is extremely helpful for boosting the performance of mobile games. The basic idea is to recycle a pool of objects, rather than continually instantiating and destroying new ones.

UPDATE:

At ~15:16 in the video, the lines copied should preferably be pasted BEFORE the call to OnObjectReuse(), so that when that method is called, the object will already have its correct position/rotation values. This could be important when resetting certain things, for example the velocity of a projectile based on its initial rotation.

Source code:

https://github.com/SebLague/Object-Pooling

Support my videos on Patreon:

http://bit.ly/sebPatreon


Game Development Support on Patreon
https://www.patreon.com/SebastianLague?ty=h
create a new empty game object
/youtube/video/LhqP3EghQ-Q?t=55.09
store our pool cues in a dictionary
/youtube/video/LhqP3EghQ-Q?t=114.31
instantiate a number of these prefabs
/youtube/video/LhqP3EghQ-Q?t=209.019
instantiate the prefab
/youtube/video/LhqP3EghQ-Q?t=234.58
bring our test manager into the scene
/youtube/video/LhqP3EghQ-Q?t=518.79999
add the cube to the prefab slot
/youtube/video/LhqP3EghQ-Q?t=578.34003
create a projected void destroy
/youtube/video/LhqP3EghQ-Q?t=1112.9091
add a trail render effect to the cube
/youtube/video/LhqP3EghQ-Q?t=1141.98