Hello,
I am trying to write a script to draw a line from a point to the position of a touch to the screen. I have been able to do this, but I cannot figure out how to make the lines from the previous frames disappear. Any help as to how to go about doing this would be greatly appreciated! My current code is below. Thank you!
void Update () {
if (Input.GetMouseButton (0)) {
drawToMouse (Vector3.zero); //as a test, drawing from center to mouse
}
}
//Draw a line from start to touched position
private void drawToMouse(Vector3 start) {
LineRenderer line = Instantiate (linePrototype) as LineRenderer;
Vector3 pointB = inputCamera.ScreenToWorldPoint (Input.mousePosition);
start = inputCamera.ScreenToWorldPoint (start);
line.SetVertexCount (2);
line.SetPosition (0, start);
line.SetPosition (1, pointB);
}