0
\$\begingroup\$
private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3 pos1 = Input.mousePosition;
            }
        }

Like two points. I click once and the click one on another position so I will have two positions and now I will be able to draw a line between them. I want to get and store two positions.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

You can gather as many positions as you want into a collection:

List<Vector2> _positions = new List<Vector2>();

void Update() {
    if(Input.GetMouseButtonDown(0)) {
        _positions.Add(Input.mousePosition);

        if(_positions.Count == 2) {
            // Draw your line, and clear the _positions list,
            // or shunt it down by one if you want the second point to
            // become the first point of the next line (use a Queue for this).
        }
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .