I have a bug (which I can’t replicate in a PG) where the player’s mesh.collider.collidedMesh.name is always “floor”, even when it also collides with a “wall”. The logic is pretty basic:
let disp = mesh.calcMovePOV(0, GRAVITY, speed)
mesh.moveWithCollisions(disp)
debugLabel.text = mesh.collider?.collidedMesh?.name
So my question is: since there can be only one collidedMesh, how does mWC decide which one to assign, when there is more than one?
The situation is not so simple
Here is the draft PG - https://playground.babylonjs.com/#6E4LSB#108
Move the box, but after several collisions one always will finish only with cylinder.
Detecting one collision works fine. The problem is detecting all collisions. The engine clearly does detect them (because it blocks movement), but collidedMesh can only point to one.
It seems that when you have a larger number of meshes, the decision of which one to report is not so clear/deterministic.
One solution I can think of is to use multiple collider meshes. One for ground detection, another for walls. But moveWithCollisions is slow already…