- Home /
RaycastHit.Normal for Meshes?
I'm using a very basic setup for placing decals on an object when the player shoots (see end of message). This works fine for mesh colliders, but when I'm using a primitive collider shape that does not match the mesh it can lead to decals spawning off the mesh of the object within the collider.
Ideally, I'd like to be able to raycast and find the normal based on the mesh instead of it's collider (after the collider raycast of course).
I see there's a MeshFilter which has a "sharedMesh (Mesh)" property, and within that class there is a triangles array. So I'm guessing you could iterate over each triangle, find the best match and return it's normal - but that seems really expensive .... is there a way to just raycast and target a mesh itself instead of having to hit a collider?
Your answer