Let’s say I have a wall with 5 materials (wood, steel & concrete). It has one MeshCollider attached. I’d like to figure out which Texture (heck I’d settle for Material) is hit when I “shoot” the wall. I don’t see the point to getting RaycastHit.textureCoord since that will just give me a collision point from which I can derive the color. There are many articles about detecting different terrain textures but an object with multiple materials is different.
So according to this article if I can get the submesh index then, according to Unity - Scripting API: Mesh.subMeshCount I’d somehow be able to get the Material?
Yep, the submesh index corresponds to the material index. So if the function in the link I posted returns a submesh index of 3 then the material index for that submesh is also 3.
That’s awesome! Thanks. I’ll check it out when I get a chance.