- Home /
Raycast or RaycastAll? And how?
Hello, I am trying to make my script work. I tried almost everything and I always get some kind of error. Could anyone tell me how to do this below*-look at image-? I think that I need to use RaycastAll? But I don't know how to check if they are same objects-by tag- and how to ignore object. My script just check first object and ray stop there-almost inside of cube, I tried changing ray distance but nothing-*. -Thanks
Answer by meat5000 · Sep 01, 2013 at 08:07 AM
Raycast using a Layermask.
http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
Set your objects up in layers in the inspector.
Use a layermask to select which layers you want to look in or ignore.
There are 32 layers (as there are 32 numbers in an int) and you select them with a binary mask.
var layermask : int = (1 << 10) //Layer 10
var layermask : int = ((1 << 10) | (1 << 14)) //Layer 10 OR Layer 14
var layermask : int = ~(1 << 10) //Every layer except 10
You can also put the int number in directly. Use the windows calculator, maybe, to convert between binary and decimal.
Your answer
Follow this Question
Related Questions
script is not working Using raycast show PopUp on click 0 Answers
GUI label on raycast? 0 Answers
problem with raycasting and functions 1 Answer
problem with touch android 0 Answers
Problem with raycast 0 Answers