In my game i have bomb explosions and this one fits well, however, i made a template out of this explosion so i can instantiate it on position of explosions, but whenever i instantiate and play particles explosion then the game lags very bad… i also tried to put it in hierarchy and playing in loop ingame but that just keeps lagging my game… does any of you had the same issue with this particle bomb effect? Or any ideas on how to reduce or better completely remove these lags from the game? But maaybe, if there was any other explosion effect that would be also great… thank you
Hi @smokys! I tried to remake your situation and it works without any lags. (I did see another problem when setting the position. To fix this, I disabled the template and enabled it by script after setting the correct position by script).
hello @Leonidas, firstly it lags more, but it keeps laging each time particles is enabled, i instantiate new explosion, enable it, and when its done explosing then it is removed… but each time it is spawned and enabled it lags
I was also thinking about that one, but then i realized that there might be more than just one explosion at one time, there might be like 3 explosions, and it would look really weird if the explosion didnt even finished and was relocated to new position and started again and so on you know…
Yeah I understand. Most games to avoid the cost of constant allocations/deallocations of memory when spawning new objects they will create a pool instead.
So it’s time a particle system finishes, instead of destroying it you will send it back to the pool. And when requiring a new one, instead of instantiating it you will grab a disabled one fro mthe pool.
Well they seem like they are smooth, because there are not much objects in game so u cant really see, but when you keep watching blue planes while dropping the bomb you can see the lags, or it looks a little like the camera was “shaking” - but its not, the shaking is turned off as it was part of the explosion…
I noticed that the screen shake is not working the first time I instantiate the explosion, but you don’t use this in your game. I suggest to disable one by one every part of the explosion to find out if there is a part that causes the lag.
I avoided the first lag when enabling the particle system for the first time by setting all of my particle systems in front of the camera and on postInitialize disabling all them, I set the pre-warm to true, also I reuse these particle systems and don’t destroy them.