Combining Camera Controller with Cannon Physics

I created the camera controller using this as reference: Camera Collisions | Babylon.js Documentation and I’m now implementing CannonJS for physics and using PhysicsImpostors. I notice that my camera now falls through if the objects are using impostors instead of ‘checkCollisions’. Same is true if the objects have “checkCollision” on and an object that is using a PhysicsImpostor, the impostor object will fall through.

Can this camera controller still be used within an environment that is using a physics engine or would I need to recreate the controller to use physics now?

@RaananW is this expected behavior of having physics + camera collisions? If so, I think we could add a note to the doc page warning about this

It makes sense that it wouldn’t work together, I assume that the physics system detects collisions differently (through impostors) compared to the “checkCollisions” type.

The physics system will take over collision detection whenever the two colliding bodies both have a physics impostor attached to them. But if your player mesh doesn’t have an impostor attached to it, then the native collision system should still work. Mixing both will result in unexpected behavior :slight_smile:

1 Like

Added a small warning to the docs so users are aware of this Add a warning about physics to camera collision by carolhmj · Pull Request #431 · BabylonJS/Documentation (github.com)

1 Like