- Home /
Drawing 2d line from a point on an object!
Hi,
I want to click on a specific point on an object(sphere) then object moves and draw a line from that point clicked.
How can i get that point coordinate and draw a line?
So thanks.
Answer by DaveA · Feb 27, 2011 at 06:44 PM
var mesh : Mesh = GetComponent(MeshFilter).mesh;
var vertices : Vector3[] = mesh.vertices;
vertices is an array, so you can index into that to get specific points.
You could use a Raycast to get the hit point on the surface. I'm not sure what point that will give, my assumption is it would be an interpolated point on a face of the surface. If that's ok, then just you that hit point. Otherwise, you'd compare that point to all the vertices in that array to find the closest one.
To draw lines, you may want to just go get Vectrosity from the Asset Store (it's free I think) or you can muck with the GS stuff.
Your answer
![](https://koobas.hobune.stream/wayback/20220613110521im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to draw a line between objects and get distance 1 Answer
Line renderer is not working for Perspective camera. 1 Answer
Smooth out a line renderer 1 Answer
line renderer question 1 Answer
Raycast trail renderer? 3 Answers