- Home /
Question by
Wasplay · Jun 16, 2018 at 08:52 PM ·
android2dlinerenderer
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 : https://youtu.be/1Gl5GV3ATo8
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); }
}
}
Comment
Ins$$anonymous$$d of a photo of your code, copy and paste the code (Remember to quote it as code)
Best Answer
Answer by Wasplay · Jun 17, 2018 at 11:03 AM
I updated Unity to Unity 2018.1.5f1 and it fixed the bug :)
Answer by Bananozuar · Jun 17, 2018 at 10:03 AM
As i presume, you mean that blue/red trail that follows player? why not use trail renderer then?
Yeah, but with a Line Renderer i have more control on the effect