Overview

Spline Trail Renderer is a simple to use component for Unity that let you have truly smooth trails combined with advanced parameters not available with default trail or line renderer.

API Reference

SplineTrailRenderer class


The main script for the trail. Simply drag it on a moving object to draw a trail.

Those are the parameters of the trail, modifiable either in the inspector or by code. For a more detailed explanation of each individual parameters, see the user guide.

    public enum MeshDisposition { Continuous, Fragmented }
    public enum FadeType { None, MeshShrinking, Alpha, Both }

    public bool emit
    public float emissionDistance
    public float height
    public float width
    public Color vertexColor
    public Vector3 normal
    public MeshDisposition meshDisposition
    public FadeType fadeType
    public float fadeLengthBegin
    public float fadeLengthEnd
    public float maxLength
    public bool debugDrawSpline

This is the spline object used to construct the trail. It can be accessed by code to get more info on the spline or move an object on it.

    [HideInInspector]
    public CatmullRomSpline spline;

Used to clear the spline, and redraw it from scratch.

    public void Clear()

CalmullRomSpline class


The underlying script that handle all spline related computations for drawing the trail.

Those are the parameters of the trail, modifiable either in the inspector or by code. For a more detailed explanation of each individual parameters, see the user guide.

Property returning the number of segments that compose the trail.

    public int NbSegments

Takes the distance on the spline from the start, and returns the position in world space coordinates at that distance.

    public Vector3 FindPositionFromDistance(float distance)

Takes the distance on the spline from the start, and returns the tangent at that distance.

    public Vector3 FindTangentFromDistance(float distance)

Computes the binormal from a given tangent and normal. Usually the normal will be Vector3.up.

    public static Vector3 ComputeBinormal(Vector3 tangent, Vector3 normal)

Length of the spline from the start.

    public float Length()

Clear the spline and remove every segments.

    public void Clear()