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
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Inherits from: Renderer
public sealed class TrailRenderer : Renderer
Remarks
This class is a script interface for a trail renderer component.
Properties
Property | Description |
|---|---|
| alignment | Select whether the trail will face the camera, or the orientation of the Transform Component. |
| autodestruct | Does the GameObject of this Trail Renderer auto destruct? |
| colorGradient | Set the color gradient describing the color of the trail at various points along its length. |
| emitting | Creates trails when the GameObject moves. |
| endColor | Set the color at the end of the trail. |
| endWidth | The width of the trail at the end of the trail. |
| generateLightingData | Configures 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. |
| maskInteraction | Specifies how the TrailRenderer interacts with SpriteMask. |
| minVertexDistance | Set the minimum distance the trail can travel before a new vertex is added to it. |
| numCapVertices | Set this to a value greater than 0, to get rounded corners on each end of the trail. |
| numCornerVertices | Set this to a value greater than 0, to get rounded corners between each segment of the trail. |
| positionCount | Get the number of line segments in the trail. |
| shadowBias | Apply a shadow bias to prevent self-shadowing artifacts. The specified value is the proportion of the trail width at each segment. |
| startColor | Set the color at the start of the trail. |
| startWidth | The width of the trail at the spawning point. |
| textureMode | Choose whether the U coordinate of the trail texture is tiled or stretched. |
| textureScale | A multiplier for the UV coordinates of the trail texture. |
| time | How long does the trail take to fade out. |
| widthCurve | Set the curve describing the width of the trail at various points along its length. |
| widthMultiplier | Set an overall multiplier that is applied to the TrailRenderer.widthCurve to get the final width of the trail. |
Methods
Method | Description |
|---|---|
| AddPosition | Adds a position to the trail. |
| AddPositions | Add an array of positions to the trail. |
| BakeMesh | Creates a snapshot of TrailRenderer and stores it in mesh. |
| Clear | Removes all points from the TrailRenderer. Useful for restarting a trail from a new position. |
| GetPosition | Get the position of a vertex in the trail. |
| GetPositions | Get the positions of all vertices in the trail. |
| GetVisiblePositions | Get the visible positions of all vertices in the trail. |
| SetPosition | Set the position of a vertex in the trail. |
| SetPositions | Sets the positions of all vertices in the trail. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |