x


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.

more ▼

asked Feb 27 '11 at 05:09 PM

user-2538 (google) gravatar image

user-2538 (google)
93 14 17 22

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
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.

more ▼

answered Feb 27 '11 at 06:44 PM

DaveA gravatar image

DaveA
26.4k 151 171 256

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3314
x132
x122
x106
x57

asked: Feb 27 '11 at 05:09 PM

Seen: 1653 times

Last Updated: Feb 27 '11 at 06:33 PM