|
Are there methods in Unity that make getting the polygon/face on a "hit surface" on an arbitrary gameobject easy?
(comments are locked)
|
|
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: http://unity3d.com/support/documentation/ScriptReference/RaycastHit-triangleIndex.html 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. Hmm what I mean are all the triangles that are parallel to each other on the same plane... for example, if you hit a side of a cube, I would like to retrieve both triangles there.
Apr 30 '12 at 11:32 PM
ina
(comments are locked)
|
