Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TrailRenderer

The trail renderer is used to make trails behind objects in the Scene as they move about.
Read time 10 minutesLast updated 4 days ago

Definition

public sealed class TrailRenderer : Renderer

Remarks

This class is a script interface for a trail renderer component.

Properties

Property

Description

alignmentSelect whether the trail will face the camera, or the orientation of the Transform Component.
autodestructDoes the GameObject of this Trail Renderer auto destruct?
colorGradientSet the color gradient describing the color of the trail at various points along its length.
emittingCreates trails when the GameObject moves.
endColorSet the color at the end of the trail.
endWidthThe width of the trail at the end of the trail.
generateLightingDataConfigures a trail to generate Normals and Tangents. With this data, Scene lighting can affect the trail via Normal Maps and the Unity Standard Shader, or your own custom-built Shaders.
maskInteractionSpecifies how the TrailRenderer interacts with SpriteMask.
minVertexDistanceSet the minimum distance the trail can travel before a new vertex is added to it.
numCapVerticesSet this to a value greater than 0, to get rounded corners on each end of the trail.
numCornerVerticesSet this to a value greater than 0, to get rounded corners between each segment of the trail.
positionCountGet the number of line segments in the trail.
shadowBiasApply a shadow bias to prevent self-shadowing artifacts. The specified value is the proportion of the trail width at each segment.
startColorSet the color at the start of the trail.
startWidthThe width of the trail at the spawning point.
textureModeChoose whether the U coordinate of the trail texture is tiled or stretched.
textureScaleA multiplier for the UV coordinates of the trail texture.
timeHow long does the trail take to fade out.
widthCurveSet the curve describing the width of the trail at various points along its length.
widthMultiplierSet an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail.

Methods

Method

Description

AddPositionAdds a position to the trail.
AddPositionsAdd an array of positions to the trail.
BakeMeshCreates a snapshot of TrailRenderer and stores it in mesh.
ClearRemoves all points from the TrailRenderer. Useful for restarting a trail from a new position.
GetPositionGet the position of a vertex in the trail.
GetPositionsGet the positions of all vertices in the trail.
GetVisiblePositionsGet the visible positions of all vertices in the trail.
SetPositionSet the position of a vertex in the trail.
SetPositionsSets the positions of all vertices in the trail.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.