Simple star dust trail in Unity

Why make things difficult? Life doesn’t need to be difficult.

I started my project to create a beautiful comet-like trail, and had plans to spend a week or more on it. In the end, however, I realized a nice looking trail can be created simply by combining two Unity components, with a little nifty scripting:
Trail Renderer
Particle System

The trail will be used to show the shot path of a basketball, so I want it to show until a make or miss is definite. This is where the particle system comes in.

I first create a prefab to hold the particle system, trail renderer, and ball trail script.
For the particle system, I use a simple star texture for the material:
six-point-star

The initial setup:
Screen Shot 2016-03-29 at 2.20.11 PM

Next I randomize the size of the particles:

increase the emission rate, and base emission off distance, so the rate is constant no matter the speed of the ball:
Emission rate

Also emit using a shape:
emission_shape

We then fade the particles over time, using color over time option. In order to select the alpha channel, you must click the top tab/arrow:
color_over_time
opacity_over_time

Next, we change the particle color to white, and add these options:
size_over_time
velocity_over_time

For the trail, adjust the time depending on desired trail length, and make start width larger then end width. Then, adjust the colors to gradually decrease alpha in order to create a fade effect:
Screen Shot 2016-04-06 at 3.48.31 PM

Finally, to add some polish, we fade the trail out using the TrailRenderer options startWidth, endWidth, and time:

And BAM!


4 thoughts on “Simple star dust trail in Unity”

Leave a Reply

Your email address will not be published. Required fields are marked *