Skip to main content
2 of 2
Use tags, make title descriptive, format code correctly
DMGregory
  • 140.8k
  • 23
  • 257
  • 401

Draw LineRenderer gradually, rather than all at once

I'm drawing a line with a LineRenderer. It works, but now I would like it the line to be drawn gradually, instead of appearing all at once.

How can I modify my code to achieve this?

using System.Collections; using System.Collections.Generic; using UnityEngine; public class LineController : MonoBehaviour { private LineRenderer Ir; private Transform [] points; private void Awake(){ Ir = GetComponent <LineRenderer>(); } public void SetUpLine (Transform[] points){ Ir.positionCount = points.Length; this.points = points; } private void Update (){ for (int i = 0; i < points.Length; i++) { Ir.SetPosition(i, points[i].position); Debug.Log (points[i].position); } } }