- Home /
Checking material on raycast
Hi, I am making a a decal system for a game. Basically I need to place different decals on different materials, so if the player shoots a brick wall I need to place a brick wall bullet hole decal. It seems that a lot of people just tag everything in their scenes and check for those tags when ray tracing, but what if you have objects made of multiple materials, then tags won't work.
Is it possible to get the material that a ray cast hits? If so, how? Is there an alternative low maintenance approach?
I also need to do something similar for stepping sounds on different materials, and I would like to avoid tags and triggers.
Answer by robertbu · Jul 01, 2013 at 03:24 PM
Here is a solution to your specific problem:
http://forum.unity3d.com/threads/53123-Get-Material-From-Raycast
And here is an answer that explains a bit more about sub meshes and walks the triangles arrays:
http://answers.unity3d.com/questions/291853/raycasthit-triangleindex-and-submeshes-which-subme.html
Thanks. That seems expensive, but it's probably the only way.
Your answer
Follow this Question
Related Questions
How to stop textures flickering 2 Answers
Simplest way to have a damage decal or texture on cubes. 0 Answers
How can I lower Decal draw calls at runtime? 1 Answer
Decal render only one object at time 0 Answers
Adding bullet holes to walls 3 Answers