Answer the question
In order to leave comments, you need to log in
How to draw a line through points?
How can I write a script in which I will specify the start and end points as well as internal points and draw a line along them?
Answer the question
In order to leave comments, you need to log in
If you are not comfortable working with LineRenderer, you can write a wrapper for it, which will take a list of Transforms and push their positions in each frame via LineRenderer.SetPosition . Something like:
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof (LineRenderer))]
public class LineRendererTest : MonoBehaviour
{
public List<Transform> points = new List<Transform>();
private LineRenderer lineRenderer;
private void Awake()
{
lineRenderer = GetComponent<LineRenderer>();
}
private void Update()
{
for (int i = 0; i < points.Count; i++)
{
var point = points[i];
lineRenderer.SetPosition(i, point.position);
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question