Are Mesh Colliders invisible from certain directions?

Hey, all,

I have a mesh collider in one of my scenes which basically enclose my camera. In order to keep the camera within this space, I use raycasts to detect where there’s a possible intersection between the camera and the world. Unfortunately, the line-cast I’m using isn’t reporting correct hits, so I was wondering if linecast collisions are only reported if the line hits the front of the collider?

I’ve checked and re-checked the code, but it’s just not working correctly at all - am I missing something?

Cheers,

SB

A collider is a collider, it has no front or back or left. Well it does, but they aren’t reported in anything.
So no, this is not collider problem.

Hmmm… this is odd, then! The collider in question is on a layer, say layer 10, as an example, and I use the following code (snippet) to shoot a line through it:

     if ( !Physics.Linecast ( Point1, Point2, out RHit, (1<<10) ) )
          Do Stuff...

I’ve even traced the line that is being cast using

     Debug.DrawLine ( Point1, Point2 );

Which passes through the object I want to detect, but the code after the if statement is still executing - any ideas?

What is the object? A cube, a plane, …

It’s basically walls of a room, but in order to save on the number of mesh colliders, there are several planes split over seperate areas of the game map - some in the vicinity of the test, others a distance away…

S7ARBVCK - did you ever fix this, I have the exact same issue. I can see the debug line passing straight through my capsule collider but not reporting a hit!

I think the key issue here is that if you start a ray from WITHIN a collider, it doesn’t detect that collider. This is a real problem when you’re trying to detect valid camera positions using rays - you need to start from the camera position and cast the ray back to the origin rather than the other way around. I haven’t come up with a solution which works 100% as yet - I’ve just had to make all my colliders in the section I want to test as thin as possible to try to catch most possible issues…

To perhaps answer the original question the way it was meant:

Colliders only exist in the direction the mesh normal faces, which normally means “to the outside direction”. The visual backface, if not existant, will also not have any collision so casting inside out will not hit anything.

This is for efficiency reasons cause testing from both sides even when not wanted (99.99% of all cases) would cost major amounts of cpu time

Nice one, Dreamora - that’s exactly what’s happening. :slight_smile: