How to create seamless comet like particle tail in Unity 3d.
In this series of articles we would like to skip all the theory, since it can be easily accessed from the official manuals. We want to show you some case studies purely practice oriented.
Let us concentrate on some practical examples and methods of their implementation. In this article, we will learn how to do a comet like tail. This can be used to visualize a trajectory of some object in your game, for instance a ball. It might also represent some super hit and hence identify its strength.
Let’s create a brand new project.
Here we create an empty GameObject by hitting Ctrl+Shift+N shortcut (Cmd+Shift+N for Mac) or you can access it via menu GameObject -> Create Empty.
In order to keep our project neat and clean from the start let’s rename it to Part_Tail.
Now we need to add a particles system, by selecting our object, then go to menu and click Component -> Effects -> Particle system.
Start Lifetime to 2;
Start Speed to 0;
Simulation Space to World;
Max Particles to 500.
Next step is to set some parameters in the Inspector. We change
Under Emission submenu, we change Time to Distance.
We go to Shape and set Angle to 0; Radius to 0.01.
Tick Color over Lifetime and click on the color bar. Then set last upper (Alpha) flag to 100
Next tick Size over Lifetime and choose the 5th (smooth decreasing) curve.
Well now, we have nice particles system, which needs to be attached to some game object, to supplement the last with some nice visual effects we’ve just created.
We create another empty game object, rename it to Ball, and add Component -> Mesh -> Mesh Filter; Component -> Mesh -> Mesh Renderer.
In Inspector, we choose sphere for Mesh Filter component and Default material for Mesh Renderer.
Then we parenting our Ball to Part_Tail by dragging the last on the first. Now I would recommend you to set 0 0 0 in the Transform, so both objects are in the same place.
Finally, to see the results of our work we need to animate our Ball in some trajectory so we apply actual distance changes to the particle system.
We select our Ball, go to the Component -> Miscellaneous -> Animation. Then we go to Window -> Animation, or use keyboard shortcut Ctrl+6 (Cmd+6 for Mac).
Click Add Curve.
We name it Movement and click Save.
Now change position of your object and after every change set new keyframe on the timeline.
Then press Play in the animation window to preview.
If you quite happy with you result and angle of view it is the time to select Main Camera and Align it to View either by clicking on GameObject Align with view or hitting on keyboard shortcut Ctrl+Shift+F (Cmd+Shift+F for mac).
Now when you hit play you can see how nicely our comet like tail works.
Depending on the results you want you can easily play further with color, Lifetime and Max Particles.
This can be utilized in sport games for balls, in shooters for grenades in fantasy for some magic shells and in space for whatever you want.