In this tutorial we will be creating a cartoon-styled collision effect that is displayed whenever an object falls or gets bumped into something. We will start by creating some sprites for the effect. Next, we will put these sprites in a particle system and customize it to our liking. Finally we will write some scripts that determine when to spawn the effect.
I created 4 colored stars in Adobe Illustrator and aligned them in a grid with a transparent background. It is important that these images are perfectly aligned in the grid because later in Unity, the particle system will try to separate them.Download Tilesheet
Next, in Unity, we will first create a material that uses our tilesheet. I will be using the Mobile/Particles/Alpha Blended shader that's built into Unity.
Next, we will be creating a particle system that can emit these star particles. In this particle system we will customize different sections.
|Size over Lifetime|
|Texture Sheet Animation|
Once the particle system is done, we turn it into a prefab called Collision Effect. We will later spawn this prefab when needed.
In this final section we will be writing an ImpactCollision.cs script that detects collision and spawns the particle system. You can find the script here. https://pastebin.com/BB55A3ZS
In the script we assign the particle system prefab. This prefab will spawn whenever the Minimum Effect Force has been reached. When the force is even stronger and the Minimum Break Force is reached, the object will break and a Destroyed Version prefab will spawn. The script also rotates the particle system around the object. To use the script, just assign it to an object in your scene. The object also needs a collider and a rigidbody.
This effect was made for a game I'm working on. I have drawn some other cartoon-looking particles and I will be using them more in the context of player/NPC interaction and dialogue.