LineRenderer working half of the time

Hi,
I have 1 bug remaining on my game that I can’t fix…
Half of the time, the LineRenderer don’t shrink for no reason !..
Here is a video of the bug and the code :
Bug : - YouTube
Code :

using UnityEngine;

public class Line : MonoBehaviour {

    public Color c;
    private LineRenderer l;
    public Vector2 pos;
	// Use this for initialization
	void Start () {
        c = new Color(c.r, c.g, c.b, 0.5f);
        l = GetComponent<LineRenderer>();
        l.startWidth = 0.5f;
        l.endWidth = 0f;
        l.startColor = c;
        l.endColor = c;

        l.positionCount = 2;
        Vector3[] a = new Vector3[2];
        a[1] = transform.position;
        a[0] = pos;
        l.SetPositions(a);
    }
	
	// Update is called once per frame
	void Update () {
        l.startWidth -= Time.deltaTime;
        if (l.startWidth <= 0) { Destroy(gameObject); }
	}
}

As i presume, you mean that blue/red trail that follows player? why not use trail renderer then?

I updated Unity to Unity 2018.1.5f1 and it fixed the bug :slight_smile: