U
U
Uncle Bogdan2021-03-09 22:06:01
Unity
Uncle Bogdan, 2021-03-09 22:06:01

How to draw a line from point to point?

The position of the line object is located at a different point, how to extend the line to another part? 6047c6d153653675624930.png
6047c70c0f1d1453709487.png
It doesn't work like this:

Line.transform.position = FirstPoint.position;
        Line.SetPosition(1, SecondPoint.position);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CHIDWI, 2021-03-18
@CHIDWI

connect the LineRenderer component

public LineRenderer lineRenderer;
    // Start is called before the first frame update
    void Start()
    {
        lineRenderer.positionCount = 3; //указываем кол-во точек
        Vector3 firstPoint = new Vector3(0, 0, 0);
        lineRenderer.SetPosition(0, firstPoint); //номер точки и её положение

        Vector3 secondPoint = new Vector3(5, 5, 0);
        lineRenderer.SetPosition(1, secondPoint);

        Vector3 thirdPoint = new Vector3(15, 5, 0);
        lineRenderer.SetPosition(2, thirdPoint);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question