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-*.
Raycast using a Layermask.
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.