How to make a user layer ignore raycasts of OnMouse* events?
Due to some reasons, I don't want to put the gameobjects of that custom layer in IgnoreRaycast layer. So is there a way in unity configurations to add another layer to the list of layers ignoring raycast?
Answer by ownerfate · Jan 13, 2017 at 11:35 PM
Check this out for more detail, Alucardj covered it well : http://answers.unity3d.com/questions/416919/making-raycast-ignore-multiple-layers.html
but this may be what you're looking for:
quoting from the topic:
Alucardj -"Now save this script, go back to Unity and attach the script to an empty gameObject or the camera (it doesn't matter, this is just a test). Now look in the inspector, click on the drop-down menu then tick the layers you wish to be acknowledged. This is much easier than trying to implement the bitshift method in the documentation. Now you've seen how it works, simply use : "
var myLayerMask : LayerMask;
// function
if ( Physics.Raycast(transform.position, transform.forward, Hit, Range, myLayerMask) )
{
// Do Stuff
}
this would just be attached to the objects that you want to be ignored, add it to the Variable.
As far as settings in unity, you can try working with the Physics2d and Physics in Edit > Projects settings. in order for it to work you may have to do a little more looking online.
hope this helped, and sorry if it didn't.
Your answer
Follow this Question
Related Questions
Ignore Raycast not working properly? 0 Answers
Count objects in a raycast 1 Answer
Raycasting else not working properly 0 Answers
Raycast Troubleshooting 1 Answer
Raycasting an object with Oculus 0 Answers