- Home /
Line erase Using Line Renderer
Hi i am new to this unity., i am writing a script which draws a line wherever the mouse position is,,,., but i want to erase the previous lines drawn..,!! using arrays.,.,!!! Its urgent., please help me out.,., here is my code,.,`var startWidth = 0.0005;
var endWidth = 0.0005;
//var aMaterial : Material;
var Line1Trace= new Array(20);
var line : LineRenderer;
var index:int=0;
var c1:Color;
var c2:Color;
var ppp = new Vector3();
var i:int;
function Start ()
{
line = this.gameObject.AddComponent(LineRenderer);
line.SetWidth(startWidth, endWidth);
line.SetColors(c1,c2);
// line.material = aMaterial;
line.useWorldSpace = true;
line.renderer.enabled = true;
}
function Update()
{
var ray = Camera.main.ScreenPointToRay ( Input.mousePosition );
line.SetVertexCount( index + 1 );
Line1Trace.push(ray.origin);
ppp = Line1Trace.pop();
line.SetPosition( index, ppp );
index++;
Debug.Log( "Ray Origin " + ray.origin);
}
`
Which lines would you erase? Do you only want the last line to be on? Last 30 lines? Do you want to erase when the user clicks the mouse, or automatically? What I'm getting to is - can you be more specific?
Your answer
Follow this Question
Related Questions
Drawing lines from mouse position 2 Answers
How to get a LineRenderer to shoot from Gun Point to Mouse Position 1 Answer
Generate a mesh around a LineRenderer 2 Answers
Filling area under positions with Mesh 0 Answers
LineRenderer renders the wrong color 3 Answers