The Trail Renderer is used to make trails behind GameObjects in the Scene as they move about.
Property: | Function: |
---|---|
Cast Shadows | Determines whether the trail casts shadows, whether they should be cast from one or both sides of the trail, or whether the trail should only cast shadows and not otherwise be drawn. See Renderer-shadowCastingMode in the Script Ref to learn more. |
Recieve Shadows | If enabled, the trail receives shadows. |
Use Light Probes | Check this box to enable Light Probes on the trail. |
Light Probe Anchor | If set, this will be used as the interpolation point instead of the Transform position. |
Materials | These properties describe an array of Materials used for rendering the trail. Particle Shaders work the best for trails. |
Time | Length of the trail, measured in seconds. |
Start Width | Width of the trail at the object’s position. |
End Width | Width of the trail at the end. |
Colors | Array of colors to use over the length of the trail. You can also set alpha transparency with the colors. Color0 to Color4 indicate the trail’s colors, from initial to final. |
Min Vertex Distance | The minimum distance between anchor points of the trail. |
AutoDestruct | Enable this to make the GameObject be destroyed when it has been idle for Time seconds. |
Light Probes | Probe-based lighting interpolation mode. |
Reflection Probes | If enabled and reflection probes are present in the Scene, a reflection Texture is picked for this Trail Renderer and set as a built-in Shader uniform variable. |
The Trail Renderer renders a trail of polygons behind a moving GameObject. This can be used to give an emphasized feeling of motion to a moving object, or to highlight the path or position of moving objects. A trail behind a projectile adds visual clarity to its trajectory; contrails from the tip of a plane’s wings are an example of a trail effect that happens in real life.
A Trail Renderer should be the only renderer used on the attached GameObject. It is best to create an empty GameObject, and attach a Trail Renderer as the only renderer. You can then parent the Trail Renderer to whatever GameObject you would like it to follow.
A Trail Renderer component should use a Material that has a Particle Shader. The Texture used for the Material should be of square dimensions (for example 256x256, or 512x512).
By setting a trail’s Start Width and End Width, along with the Time property, you can tune the way it is displayed and behaves. For example, you could create the wake behind a boat by setting the Start Width to 1, and the End Width to 2.
You can cycle a trail through 5 different color/opacity combinations. Using different colors could make a bright green plasma trail gradually dim down to a dull grey dissipation, or cycle through the other colors of the rainbow. If you do not want to change the color, it can be very effective to change only the opacity of each color to make your trail fade in and out at the head and/or tail.
The Min Vertex Distance value determines how far an object that contains a trail must travel before a segment of that trail is solidified. Low values like 0.1 create trail segments more often, creating smoother trails. Higher values like 1.5 create segments that are more jagged in appearance. There is a slight performance trade-off when using lower values/smoother trails, so try to use the largest possible value to achieve the effect you are trying to create.