Keep box upright by fixing rotation

Hello,

I’m going to create a TPS/FPS game using Babylon.js

I try to let players (boxes) stand upright and stack together after collision detection by physics engine. However, the reaction force makes them bounce and slide:

https://www.babylonjs-playground.com/#NGSGCJ#4

How can I “turn off” reaction force in physics engine and make the movement of boxes looks like FPS game, like CS? Many thanks!

mmm… I found out that for my case, I should better use moveWithCollision with a Vector3 adding up with all movement changes

I am making my own fps too!

I use object.rotationQuaternion.x = 0; and object.rotationQuaternion.z = 0; in the register before render function. object.rotationQuaternion.y = 0; would prevent the player from looking sideways.
But that might be an issue, as I use 2 spheres and a cylinder to make a capsule, and a custom movement function. Also, good luck finding a solution to slopes! aka “stair clipping”. One way is to turn off gravity when on slopes. My fps is going to be different from others just so I could avoid that issue. Can’t wait to see it come out!

You can announce it under the games/projects category on the forums!

Welcome to the community!

Givo

PS. Here is my playground for the fps: https://www.babylonjs-playground.com/#IFN77Q#52

I was stuck on looking left/right when stopped because I used .sleep when not moving to prevent sliding down slopes. I didn’t find a solution, but feel free to copy any code you like.
giv0.gitlab.io/fpsg (wait for the model city to load) was my first fps attempt. because it uses the default camera movement/gravity, jumping is not possible. Controls:

WASD move
C toggle crouch
SHIFT run
F toggle freecam
RIGHT CLICK aim

ctrl-u to see the code. click on the js file.

Good luck!

2 Likes

I have since changed how the fps is going to play. It should make it fun and interesting to play.