- Home /
Question by
Orcka · Jun 10, 2018 at 10:56 PM ·
scripting problemlinerenderer
How to have the line renderer render multiple lines at the same time
I want to be able to produce 3 lines from 3 dot sprites simultaneously when I hold down the mouse button:
public void Start()
{
sprite1 = GameObject.FindWithTag("South");
sprite2 = GameObject.FindWithTag("North");
sprite3 = GameObject.FindWithTag("Center");
m_SpriteRenderer = GetComponent<SpriteRenderer>();
_lineRenderer = gameObject.AddComponent<LineRenderer>();
_lineRenderer.SetWidth(0.1f, 0.1f);
_lineRenderer.enabled = false;
}
private Vector3 _initialPosition;
private Vector3 _currentPosition;
public void Update()
{
if (Input.GetMouseButtonDown(0) && _overVertex == true)
{
_lineRenderer.SetPosition(0, sprite1.transform.position);
_lineRenderer.SetPosition(0, sprite2.transform.position);
_lineRenderer.SetPosition(0, sprite3.transform.position);
_lineRenderer.SetVertexCount(1);
_lineRenderer.enabled = true;
_lineRenderer.material = _lineMaterial;
_lineRenderer.startWidth = _lineWidth;
}
else if (Input.GetMouseButton(0))
{
_currentPosition = GetCurrentMousePosition().GetValueOrDefault();
_lineRenderer.SetVertexCount(2);
_lineRenderer.SetPosition(1, _currentPosition);
}
But this only generates one line, the last line called, and in this case it is from sprite3, the center dot on line 26.
How do I make it so that the line-renderer renders all 3 lines simultaneously?
What i tried to do was implement 3 line renderers instead of one, but the issue remained the same.
Comment