How to disable trail renderer

I add trail renderer for my bullet. I am also using object pooling.
When I reuse by bullet the trail renderer draw all over the screen.

I tried enable and disable but it does not work.

Is there a way to disable trail renderer?

To anyone who still has this problem in 2017. Use myTrailRenderer.Clear()

When you reuse the bullet set

gameObject.GetComponent<TrailRenderer>().enabled=false; 

to disable the trail render.And on firing the bullet, set it to true.

The code I have so far. I wrote it by checking out someof the posts in the site. It look OK most of the time. But sometimes it does not work

    private TrailRenderer line;
    private float _trailTimer = 0.1f;
    private bool alive = true;

    private Vector3 movingDirection;

    void Awake()
    {
        line = gameObject.GetComponent<TrailRenderer>();
        line.time = -1;
    }

    // Use this for initialization
    public virtual void Start()
    {
       
        gameObject.renderer.enabled = false;
        trans = gameObject.transform;
        spentLife = lifeTime;

    }

    public virtual void Init(CreepAI target, Vector3 startPosition, float damageAmount, float areaOfEffect, string damageCauser)
    {
       
        this.damageAmount = damageAmount;
        this.areaOfEffect = areaOfEffect;
        this.damageCauser = damageCauser;

        movingDirection = Vector3.Normalize(target.gameObject.transform.position - gameObject.transform.position);

        

    }

   
    // Update is called once per frame
    protected virtual void FixedUpdate()
    {
       

        if (line.time <= 0.0f)
        {
            _trailTimer -= Time.fixedDeltaTime;
            if (_trailTimer <= 0)
            {
                gameObject.renderer.enabled = true;
                line.time = 0.50f;
                _trailTimer = 0.1f;
            }
        }

        trans.position += movingDirection * Time.fixedDeltaTime * speed;

       
        spentLife -= Time.fixedDeltaTime;

        if (spentLife <= 0.0f)
        {
            line.time = -1;
            ObjectPoolManager.DestroyPooled(gameObject);
        }



    }

    void OnTriggerEnter(Collider other)
    {
        line.time = -1;
        DestroyProjectile();


    }

    public virtual void DestroyProjectile()
    {
        gameObject.renderer.enabled = false;
        ObjectPoolManager.DestroyPooled(gameObject);

        
    }

I’ve got a similar issue… I’m making a game with a rolling ball for android. And in this game is a teleporter, but every time if the ball (the ball has a trail) passes trough the teleporter you can see the trail going from teleport pad A to pad B … very annoying. I tried to stop it but it did not work out.

public void OnTriggerEnter(Collider other) { other.GetComponent<TrailRenderer>().enabled = false; other.transform.position = Destination.transform.position; other.transform.rotation = Destination.transform.rotation; other.GetComponent<TrailRenderer>().enabled = true; }

Its simple, put Trail render component in empty node under object with trail and use gameObject.setActive() for this child node

I know this question is ancient, but I ran into the same issue. All you need to do is Clear() the trail in OnEnable() like so:

private void OnEnable()
{
	GetComponent<TrailRenderer>().Clear();
}

TrailRenderer.Clear() Documentation