- Home /
Is it worth object pooling two particle systems?
Hi all, Im aiming to release a simple kids matching game on android. When a match is made an instance of a particle system prefab is created at both positions of the matched objects. Is it worth creating two PS's and resetting and re positioning for each match? My prefab fires all particles at once. So how would I reset it?
cheers
Answer by TwisterK · Dec 17, 2013 at 02:51 PM
if you plan to release on mobile platform, it is always recommend to use pooling as Instantiate and destroy objects often cause performance spike on the device.
To implement pooling, all you have to do is instantiate the two objects during awake, then set game object to inactive. When you want to use it, just re-activate it and call Play method ( if you using shuriken system ) to emit the particle, once you done with the particle, call Stop and Clear method and de-active the game object.
Here are the sample code to Play the particle system.
Answer by Owen-Reynolds · Dec 17, 2013 at 03:00 PM
Reset with the Play command: PS1.particleSystem.Play();
. Uncheck the Loop box so it fires once, then never again, so won't have to stop it. But you could still have a coroutine SetActive(false) after 5 seconds, if you're really worried.
But, will they ever make a new match while the old is still fading away? Then you'd want extra particlesystems. In that case, the game is probably fast enough that you can just Instantiate/Destroy.
There probably could be another match made while the first particles are still fading. But i dont see that as being much of an issue. The new explosions should distract the player. If it doesnt look right I can just use 4 particle systems. Thanks for the answers :D