I would love for someone to help me with getting the correct settings of my game right, because I am really lost.
I have a terrain with hills and abstract shapes and my player is a sphere that I want to be able to roll over the landscape.
You can visit the website here: https://staging.subneu.live/
You need to toggle gravity by clicking the G key in order for the physics to be enabled!
I am using ammo.js which is a javascript port of Bullet. https://github.com/kripken/ammo.js/
first off, in order to move the player I am currently using the setLinearVelocity() method which is triggered while holding the arrow keys every update. This works, but I believe it is not the best way since by setting the velocity the gravity of the world is circumvented/ignored? So I probably need to use setForce or setImpulse, but I am not getting it correctly.
some code:
Code: Select all
const moveRigidBodyWithVector = (body:any, vector:any, scaleFactor:number) => {
const resultantImpulse = new Ammo.btVector3(vector.x, vector.y, vector.z) // eslint-disable-line
resultantImpulse.op_mul(scaleFactor)
physicsBody.setLinearVelocity(resultantImpulse)
}
- world gravity : Ammo.btVector3(0, -100, 0)
- mass of sphere : 800
- friction of sphere. : 4
- rolling friction of sphere. : 10
I just want my game to have normal earth-like physics + the sticky but easy-to-roll sphere on the terrain moving around with controls.
Any help so much appreciated!!!
Thank you.