Hi babylon community
I have a very simple scene with a floor and four walls. It has a first person controller. The problem I cannot figure out is why the walls with doors (in the playground below) cannot be penetrated but the other two walls are penetrated. In fact it has a weird behaviour where the camera is “attracted” before further going through the wall. The doors are irrelevant for the problem (just for orientation), if you remove them the behaviour does not change.
There have been workarounds proposed in the past to similar problems (additional invisible walls or cubes intead of planes). It seems to me that it must be something Im doing wrong given the assymetry of the problem and the maturity of babylon.
The problem can be checked here:
The problem relates to wrong (inverted) normals.
I corrected normals for both ‘problem’ walls here - https://playground.babylonjs.com/#JUKXQD#4681
But better to do it at model level in some DCC tools like Blender, so you wouldn’t need to run addtional code for this.
Thanks so much for finding (and solving) the problem ! would you say that the way babylon deals with this is OK? I would have expected that collision is still active or that it does not work at all.
Shortly, you just need a correct GLB model in order for collisions to work properly.
If you are not able to change your model (which is preferrable way), you need to correct it after loading with Babylon.
Here is one of the simplest examples of correct model with correct collisions - https://playground.babylonjs.com/#0VHCTL#32
FYI: I have asked this question recently and the answer is that it’s ‘by design’ and essentially to save performance. Checking collisions on both sides would be mostly unnecessary and would also create a bunch of other issues. From what I understood, there’s no plan to change this soon (at least not before v6 is out). In most cases, you need collision just on one side and you can simply fix your normals as per @labris info and tip to fix in BJS. In case you need both sides, either give your mesh a volume, create an invisible collider for the backside or create an invisible instance of the mesh (rotated or with inverted normals).
Sorry for the late reply and thanks for the info. Yet I struggle to understand why that is a performance issue, as (I would assume) you detect collision with planes not with faces … nevermind
Adding @Cedric who might have answered the related thread @mawa talked about.