Using LineRenderer, how can I draw a single path passing through more than two points?
I am currently drawing a continuous straight line starting from a fixed point ending at the touch position. What I want to do is make the line bend when there is a collider in its way and continue making a path. I am detecting the collider with raycast along the line but how to bend the line?
You can see an illustration of what I am trying to say in the following picture. Thanks.
Answer by Baste · Feb 15, 2016 at 01:27 PM
You have to set the positions array of the line renderer to have three points (or as many as you need). In your case, it would be something like:
Vector3[] positions = new Vector3[3];
positions[0] = blackCircle.position;
positions[1] = yellowCircle.position;
positions[3] = redCircle.position;
lineRenderer.SetPositions(positions);
Thanks a lot for your help. Just to be clear, your piece of code is not working in C# because there is no function that I could find named "SetPositions". To use multiple points in your LineRenderer you must increase its vertex count first using
lineRenderer.SetVertexCount(whatevercount); and then set all the positions one by one. $$anonymous$$y main goal is to make the corners of the linerenderer smooth as well. How do you figure I can achieve that?
Your answer
Follow this Question
Related Questions
Raycast line renderer not drawing correctly 0 Answers
Moving dotted guide line 0 Answers
LineRenderer Raycast Gun Bug 1 Answer
LineRenderer doesn't go to Hit.Point 1 Answer
Line Renderer on top of Mesh 1 Answer