schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.71k stars 709 forks source link

Gravity issue?! #338

Open gniiial opened 7 years ago

gniiial commented 7 years ago

Hey there,

i've made a scene with just an orb (to check collision behavior with it), a playerbox (75,150,75) and a collision fakebox(150,150,150). Both boxes use cannon.box, the orb uses the cannon.sphere. The gravity is set to -980 on y and i use angularDamping every step to prevent the playerBox rotation when there is a collision with something. If i jump on the fakebox, which has the same mass like the player 5000, and try to stay on it, the gravity pulls me down somehow. I dont do anything, just staying in the center of the fakebox. Then when im on the ground again the behavior stops and the playerbox dont move any step by itself. Is there a bug with the gravity?!

It happens faster when i set angularDamping to 1, and if i turn it of (by //) it takes i would say just twice the time. Its like the worlds angle is not really static.

Edit1: Seems playerBox.fixedRotation = true; stops the effect. So i can use angularDamping, set it to 0 when i want to rotate and to 1 when i just move my playerBox around. I just hope it causes no other things i can't see comming at the moment.

Edit2: I had to reopen the issue because it was just a "lucky" constellation of movement and positioning on the fakeBox. The thing is if i jump on that box, i slide down to the ground. But when i then just turn left or right (y rotation), then my playerBox stays on the fakeBox. Something is right in the .fixedRotaition part, what should be right in the gravity/world part of cannon itself.

TerryHibbert commented 6 years ago

Hey @gniiial, those values seem a bit high. Have you tried scaling things down a bit? For example, the readme sets the gravity at 9.82 (m/s²). Just a guess, but the engine may be tuned for more human scales.