- Home /
Question by
Kek_Kek · Jun 22, 2018 at 12:47 AM ·
linerenderer
Is it possible to have a gameObject as a point on a Line Render
Just Wondering but is there any way to add a gameObject as a point on a Line Render.
For example, I have a grappling hook and when I press A, the line draws out with a hook object attached to the endpoint.
Comment
Answer by LeeroyLin · Jun 22, 2018 at 04:16 AM
You can get the LineRenderer component and set the points like this:
LineRenderer lr = GetComponent<LineRenderer>();
List<Vector3> points = new List<Vector3>();
points.Add(new Vector3(0, 0, 0));
points.Add(transform.position);
lr.SetPositions(points.ToArray());
You can set the vector3 array to the LineRenderer component, so you can use the game object's position.
Hope this can help you.
Your answer
Follow this Question
Related Questions
Raycasting along line renderer width 1 Answer
Raycast trail renderer? 3 Answers
Clearing a LineRenderer Whiteboard, so that you can start drawing again 1 Answer
Vector direction to point 1 Answer
How draw a path using touch in c# 1 Answer