Physics Imposter and Physics Engine Questions

I’m using Oimo.js for my FPS game, it’s a great engine for realistic collisions, but I’m lacking control in achieving certain artifical effects.

  1. Is the best way to prevent the impostor from rotating when it collides (etc when it hits a sharp corner) to set the angular velocity to zero on every tick and use only linear velocity to move around instead of impulses?

  2. How do I ensure that a physics imposter only starts falling if everything under it is empty? Right now, it falls when it’s center of mass is over the edge. This is realistic, but the impostor is clipping the edges of cliffs when it falls since I’m preventing it from rotating. I also just want players to be able to go all the way to the very edge.

  3. How do I control movement on slopes? I assume that the rate at which my object slides has something to do with the angle of the slope, mass and friction, but how do I prevent players from sliding altogether and allow them to traverse it statically like on flat ground?

I don’t know if any of the current physics libraries address these issues or if there are shortcuts, or if I have to make my own engine altogether. :woozy_face:

Pinging @Cedric

Hi @erey

I know a bit more about ammojs.There is an existing character controller that you can create and would fit your needs.
There is this thread I found on the forum : Handling Ammo Kinematic Character Controller
A web search on ‘character controller ammojs’ will give you more results

Also, depending on your needs, maybe a physics engine is not the only solution. You can use a navigation mesh and constraint the player on that mesh. You’ll get more controls and visual feedback on allowed surfaces.

Check this thread for more details : Constraining a UniversalCamera on a Navigation Mesh

Hey @erey, as @Cedric mentioned, a physics engine is not the only solution.

Here’s an example using Raycasts and moveWithCollisions:

Please click inside the Playground for pointerlock and use WASD for movement and SPACE for jump.
https://www.babylonjs-playground.com/#3EDS3A#16

1 Like