• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by mathmos_ · Jul 01, 2013 at 03:06 PM · textureraycastmaterialdecal

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mathmos_ · Jul 02, 2013 at 03:51 PM 0
Share

Thanks. That seems expensive, but it's probably the only way.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to stop textures flickering 2 Answers

How can I lower Decal draw calls at runtime? 1 Answer

Simplest way to have a damage decal or texture on cubes. 0 Answers

Decal render only one object at time 0 Answers

Adding bullet holes to walls 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges