- Home /
Getting the position of an object's specific tri
Hi!
I wondered if it's possible, to get the exact position of a tri of an object. I'm using raycast and RaycastHit.triangleIndex to get the id of the specific tri, but i couldn't find a function or variable to get it's position.
Answer by Rett_ · Mar 07, 2013 at 10:23 AM
Technically speaking, tris do not have a position. They are defined by their vertices. You can access them with something like this:
Vector3[] vertices = meshWeHit.vertices;
int[] trinagles = meshWeHit.triangles;
Vector3 vertex1 = vertices[triangles[triangleIndex * 3]]
Vector3 vertex2 = vertices[triangles[triangleIndex * 3 + 1]]
Vector3 vertex3 = vertices[triangles[triangleIndex * 3 + 2]]
Edit: why don't you use RaycastHit.point?
thanks, i'll try that. i don't use RayCastHit.point because i need a very accurate measurement.
Your answer
Follow this Question
Related Questions
Having an object point towards mouse position in 3d world 1 Answer
Raycast Specific Object/Instantiate Explosion 1 Answer
Negative Positions Breaks Raycasts 1 Answer
Changing position of a RayCast 1 Answer
Instantiating Object On Map 1 Answer