How to create a trail in Unity3D?

How to create a trail in Unity3D

Trails are a common sight in every mobile game these days. Be it a fired bullet or the blade swoosh of Fruit Ninja, they are everywhere. You would definitely need to employ trails in any of your games anytime. So, how do you make this trail? This free unity 3D scripting tutorial can help you out with that.

We will use the trail renderer feature of Unity game engine to create the this effect. Go to the trail renderer component and add this to an empty game object.

There are some major properties within the trail renderer that you would need to specify in order to get the desired effect that you want with your trail.

  • Materials: Use default material or create a new material and set to Mobile/Particles/ Alpha Blend.
  • Time: Length of trail in Seconds.
  • Start width: Width of trail at start.
  • End width: Width of the trail at the end.

Other properties are kept default.

Now, write the code as shown here in the tutorial. You can also download this unity 3D game source code for free and tweak the parameters by yourself. After you have written the code, attach it to the object to which you have assigned Line Renderer.  You’re done!

Please note that Line Renderer has been introduced in Unity since quite some time and many people have been using it. It is available across all the version of Unity.

Have a great time creating your own trail. Next time we would learn to create our own augmented reality simulation in Unity. Cya!!

Related: What are the common types of Game Assets?

Leave a comment