I have a well. The well is split in 3 mesh renderer materials. You throw rocks in the well with physics. I want the rocks to make a sound when they collide with the well. The sound needs to be different depending on which renderer material of the well it hit.
The first thing I tried was to split the mesh in 3 meshes and have each their own collider, then check which collider is the collision happening with and play a different sound.
This works, BUT, weird things happen in the seams between the colliders (like if a rock goes right between two colliders it goes off in bizarre angles, this doesn’t happen when it’s all one continuous mesh collider).
So I need this to be one single mesh collider.
But if it’s a single mesh and one mesh collider how do I detect which renderer material I am hitting?
I’m thinking of getting the collider contact point, then raycasting to it, so I can then query hitinfo and get triangles, or UV coords or something and use that to figure out which material I’m hitting.
This will probably work, but it seems really roundabout.
Am I missing some other more obvious and easier way to go, or is this it?