I’ve got a scene with gameobjects with mesh colliders and layer set to a custom layer called “outer space”.
I try to shoot rays from the camera to these objects, so I have a script attached to the camera where I do:
if (Physics.Raycast(transform.position, transform.forward, hit))
//...
and that works,
but when I do:
if (Physics.Raycast(transform.position, transform.forward, hit, Mathf.Infinity, LayerMask.NameToLayer("outer space")))
then I get no hit.
Any idea why it doesn’t work ?
(there are other objects in the scene with a different layer, which I do not want the raycast to hit)