Issues with physics engine and loaded model (falling thru floor etc.)

Hi there,

I have issue with using physics engine with player, npcs and loaded model. See following example:

If you set const useCannon to true things go funky and player will fall thru floors. I have been reading documentation and all should be ok, but I don’t know what am I missing.

The purpose is that both the player and NPCs fall to the floor, and the player can control itself. When the player collides with an NPC, the physics will take effect. Player needs to be able to climb stairs and so on. Basic stuff.

Example is using Cannon but if Havok is better that will work too.


Havok seems to be working better: Babylon.js Playground ( (I simplified the PG a bit so it was easier to see what’s going on)

1 Like

Here’s a PG with character running around your mesh:

I’m currently working out how to get the player’s physics to interact with the worlds physics. WIP here: Make car crash into pillars (moving a havok physics object with mouse controls) - #11 by bigrig

Here’s a better PG with character surrounded by physics capsule - and objects (loaded GLBs) that you can add to the scene.

1 Like

Thank you @carolhmj I’ll go with Havok. Seems to work great! Controls (mouse & keyboard) no longer works when using Havok. I’ll figure it out. There was another thread about controls with Havok, but it did not had mouse control either.

@bigrig your example looks great, but at this point CharacterController library feels little overkill. Is it documented somewhere or where does it comes from?

You’re updating the player’s position/rotation directly based on the keyboard/mouse inputs, right? Then you’ll need to set disablePreStep = false on the player’s physics body. We usually skip updating the physics body’s position with the mesh’s position to increase performance, but in this case it will be needed. Alternatively, you can use velocities to update the player, but this requires changing more stuff.

Yes, see comment at top of pg. Docs there. Cheers