x


Selecting a single polygon / face at runtime

I'm wondering if there is a more direct way to select a single polygon/face at runtime other than (touch, highlight poly):

1) raycast mouse to poly

2) search positions to find which set of vertices that's closest to

3) convert vertices to nearest face

4) "highlight" the poly/face to show that it's been selected

more ▼

asked Dec 21 '10 at 07:14 PM

ina gravatar image

ina
3.3k 492 549 597

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

1 answer: sort voted first

If you use a mesh collider, then you have access to RaycastHit.triangleIndex. Highlighting the selected face could still have some difficulty, though. Unless you're sure that every single vertex in the mesh is split, it would probably be easier to construct a new mesh that consists of a single face, and position it in the same spot as the selected face.

more ▼

answered Dec 21 '10 at 09:04 PM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

Okay, so position the new mesh according to RaycastHit.point pointing towards RaycastHit.normal. How do you know what size to create the new "2d poly" mesh?

Dec 22 '10 at 06:14 AM ina

See the example in the docs for RaycastHit.triangleIndex

Dec 22 '10 at 06:46 AM Eric5h5

why is this mesh only? why doesn't this work for default cubes in unity?

Apr 30 '12 at 11:35 PM ina

Also is there a way to check if surrounding triangles are parallel to the currently hit triangle?

May 01 '12 at 02:36 AM ina

Hmm, so I've been puzzling over this for quite some time... How do you construct the new mesh that consists of the single face? (How do you know which triangles this is?)

May 01 '12 at 06:17 AM ina
(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:

x1357
x300
x139
x64
x55

asked: Dec 21 '10 at 07:14 PM

Seen: 2309 times

Last Updated: May 01 '12 at 06:17 AM