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.
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.
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?