How do I make a particle effect like the one in the image in a 2D game?
And how to I get the shadow effect?
Thanks.
How do I make a particle effect like the one in the image in a 2D game?
Hm.
Seems like a simple line renderer. Problem is, I haven’t ever had much luck getting a LineRenderer to work well in 2D - but I’m sure there are 2D line renderer scripts floating around somewhere. That will probably be your best bet.
If that doesn’t work out, you may want to investigate the Graphics API and/or the GL API that Unity exposes. Then you can write said functionality from script. Basically, just create a mesh at runtime, and add line segments to the mesh as your object moves.
Try out the TrailRenderer component for the colored lines.
The shadows would be much more complex to create. There are a few assets that can accomplish that though:
This one uses raycasting and is free for the basic version:
This one uses mesh projection and vertex shaders:
Do trails work in 2D too?
Yes, LineRenderer and TrailRenderer will work with 2D if you assign the default sprite material to them, and set their SortingLayer and SortingOrder like you would a sprite.