Unity Optimized Particle Explosions

For A Dragon Named Coal in Unity, I needed an optimized way of exploding crates, windows, enemies, and other common items. Here I’m going to give a quick overview of how we accomplished the GIF effect above in an optimized fashion.

We were doing this on the fly with random number generation (RNG). But when the user destroyed several items at once the RNG caused FPS drops for a split second. Quite annoying if you hit a crate in the middle of combat. Things were even worse on older machines where the FPS dropped for several seconds.

The solution to solving the issue was pre-caching all the RNG in the script below. You can drop this in any 2D project and it will magically work. If you need 3D support just tweak the Vector2 properties for Vector3 compatibility.