Are there methods in Unity that make getting the polygon/face on a "hit surface" on an arbitrary gameobject easy?
asked Apr 27 '12 at 09:54 PM
In Unity, all objects are made up of meshes and meshes are made up of triangles. So when you ask about getting the polygon/face of the hit surface, I think what you are asking for is the identity of the triangle that was collided. When a collision occurs, we are given information about the collision including the point in world space where the collision happened. Our goal then would be to map that 3D point to the triangle of a mesh. It seems that if we cast a ray "close" to that point and "through" that point, we will generate a RaycastHit object. See:
This object has a property called "triangleIndex" which is an index into the array of triangles that compose the mesh that was struck by the ray ... and hence the triangle which was struck.
answered Apr 27 '12 at 10:11 PM