Question by
Cornelis-de-Jager · Aug 28, 2016 at 12:34 PM ·
raycastlayers
Raycast NOT ignoring layers
I have a problem where my raycast does not want to ignore any layers except for the ignoreraycast layer
// Ray cast
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
LayerMask layer = LayerMask.GetMask("Plane");
// Do ray cast
Physics.Raycast (ray , out hit, layer); // Hits "Event" Layer instead of Plane Layer
Comment
Best Answer
Answer by mj321 · Aug 28, 2016 at 12:41 PM
Physics.Raycast has many overloads, but i think the third parameter is the distance, not the layer mask.
You want to do -->
if (Physics.Raycast(ray, out hit, $$anonymous$$athf.Infinity, layer$$anonymous$$ask ))
Your answer
Follow this Question
Related Questions
How to make a user layer ignore raycasts of OnMouse* events? 1 Answer
Use Layer Collision Matrix for Raycast 1 Answer
Why won't Physics.RaycastNonAlloc mask layers properly? 1 Answer
Make everything above the floor my player is standing invisible when my camera cant see my character 0 Answers
How to get raycast to ignore objects behind a panel 0 Answers