Physics.Raycast - Not Hitting Backside of Mesh/Poly?

I have a case where theres a building which has no interior, and I want to check how far down my character is after animation a “vault over fence”. The problem is, that after the animation the characters location is slightly “below” the surface of the building.

I’ve noticed that doing a raycast down works fine from above the surface, but in the case above my raycast upwards finds - nothing! Even though there clearly is a plane above them.

So my question is if there is a setting to ensure that raycasts consider the plane from both sides? Is this happening because the backside is being culled and so unity3d considers this off the table for raycast hits?

You can enable Physics.queriesBackFaces (added in Unity 5.5)

It’s not possible to make raycasts check both sides. If you need both sides to be hit, then you have to model both sides.

All primitive colliders have no “interior”. It’s the default concept how nearly all collision systems work. Only if you use a non convex meshcollider and like Eric said you’ve modeled both side you can collide with both sides. Convex mesh colliders behave like every other primitive collider, so there are no “backfaces”.

In your case you could start your raycast with an offset. Just shift the starting point upwards say 1.0. If you want to “measure” the distance you have to subtract the offset from the returned distance.
But watch out: The resulting distance can be negative (since you are slightly below the surface). Also keep your offset as small as possible. If you offset it 10m you will hit the second floor inside a building :smiley: