Im building myself little Tower Defense game, and at the moment Im trying to fix some minor problems with the scripts. When my turret fires I have it Instantiate a particle effect at the muzzle (a little smoke plume and flash), which looks great and works, kinda of. I noticed while testing that the way I have it set up, its creating a new particle effect every time it fires, so after a bit of fighting there are dozens of particle effects building up in the hierarchy, no good for optimization. What would be the best way to fix this? My first thought would to have it destroy the effect after it fires, but it seems there has to be a better way of programming it than that. Any thoughts?
A lot of people create expandable pools of resources. In your case you can have a pool of “shot” particle effects. Or even on a higher level, if your effect is connected to a “bullet” (and I use the term “bullet” loosely) then you can create a pool of bullets.