How can I prevent a raycast from detecting a trigger?
I’m simply checking if the raycast hit’s anything.
forwards = Physics.Raycast (transform.position, -transform.forward, 0.5f);
Btw, most of the time I’m inside a big trigger, and it’s colliding against the edge of the trigger from the inside.
Do this:
Go to: Edit → Project Settings → Physics → Raycasts Hit Trigger
And set that to false.
You need to filter using layers.
Your trigger collider needs to be assigned to a layer that your raycast won’t flag as a hit.
To do this use
Thank you for this post, I don’t understand why by default a raycast would hit a trigger in Unity.
Raycast is a linear sensor and a collider set to trigger/true is a volumetric sensor, sensors should never detect other sensors by default. That’s like a laser pointer setting off a landmine.
It took me too long to figure out it was even a raycast causing my issue, I originally thought the trigger checkbox was bugged. You have brought me peace.