Recycled trailers leave streaks...

How to reset the trail of a trail renderer so when I recycle and reactivate pooled objects they don't leave streaks?

I've tried turning off the TrailRenderer and ClearParitcles on the particle emmiter when they are reused but with no joy so far...

Example Bullets, 1 Created/Recycled sets position and rotation (reactivated) 2 Fired adds velocity 3 Stop/Explode 4 Deactivated - Velocity Zeroed 5 Pooled 6 Reused back to 1

Am I missing something, in effect I want to restart/reset the trail when I reactivate the object?

New Unity version has a Clear method for trails: Unity - Scripting API: TrailRenderer.Clear

If this option is not available for you I recommend resetting the time in the OnRenderObject callback of your script:

    void OnRenderObject()
    {
        if (!float.IsNaN(_ClearTimeS))
        {
            _TrailRenderer.time = _ClearTimeS;
            _ClearTimeS = float.NaN;
        }
    }

    private float _ClearTimeS = float.NaN;

    public void Clear()
    {
        if (!float.IsNaN(_ClearTimeS)) return;
        _ClearTimeS = _TrailRenderer.time;
        _TrailRenderer.time = 0;
    }

You should make a prefab for your bullet and add a TrailRenderer, use Instantiate to use your bullet and Destroy after collision or explosion. This activates and kills your TrailRenderer as desired.

See Also: In depth Prefab Instantiate discussion

What worked for me is this:

//Declare your temporary timer.
private float _trailTimer = 0.1f;

void YourFunction()
{
     this.gameObject.GetComponentInChildren<TrailRenderer>().time = 0f; //Disable the Trail Renderer.
}

void Update()
{
        //Reset the trail of the TrailRenderer so that it wont glitch through the 
        //screen while pooling the object.
		if(this.gameObject.GetComponentInChildren<TrailRenderer>().time == 0)
		{
			_trailTimer -= 1 * Time.deltaTime;
			if(_trailTimer <= 0)
			{
				this.gameObject.GetComponentInChildren<TrailRenderer>().time = 1.5f;
				_trailTimer = 0.1f;
			}
		}
}

function FixTrail()
{

	var tr : TrailRenderer = GetComponent(TrailRenderer);
	var tmp : float = tr.time;
	tr.time = -1;
	yield;
	tr.time = tmp;
}