D
D
Dmitry Korolev2016-04-08 21:41:10
C++ / C#
Dmitry Korolev, 2016-04-08 21:41:10

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

2 answer(s)
D
Daniil Basmanov, 2016-04-11
@adressmoeistranici

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);
        }
    }
}

Or take the Vectrosity plugin , maybe it will be more convenient with it.

V
Vitaly Pukhov, 2016-04-09
@Neuroware

google in the direction of approximation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question