- Home /
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
Answer by Eric5h5 · Dec 21, 2010 at 09:04 PM
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.
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?
why is this mesh only? why doesn't this work for default cubes in unity?
Also is there a way to check if surrounding triangles are parallel to the currently hit triangle?
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?)
Your answer
Follow this Question
Related Questions
Mirror vertices procedurally 2 Answers
MeshCollider is not getting updated when adding vertex to mesh 1 Answer
sharedMesh - what is the mesh shared with? 1 Answer
UV-ing a sphere procedurally 1 Answer
Bounds of dynamic mesh not updating 1 Answer