Replies: 4 comments 3 replies
-
I'm curious about this as well. A simple fix would be to run
|
Beta Was this translation helpful? Give feedback.
-
@SuboptimalEng you mean to counter gravity? Id rather not, if there is no option yet maybe it can be added as it should be rather simple |
Beta Was this translation helpful? Give feedback.
-
Just jumped into the code to see what you meant. If I understand it correctly, a better option could be to add https://github.com/pmndrs/cannon-es/blob/master/src/world/World.ts#L539-L551 I'm super new to this btw. Started learning Cannon.js + game dev physics two days ago. |
Beta Was this translation helpful? Give feedback.
-
Hey! To make only an object appear gravitless, you have to apply an equal and opposite force to the object before each step. const world = new CANNON.World()
world.gravity.set(0, -9.81, 0)
const body = ...
world.addEventListener('preStep', () => {
body.applyForce(new CANNON.Vec3(0, 9.81, 0)) // opposite of gravity
}) |
Beta Was this translation helpful? Give feedback.
-
Hello,
is it possible to set a body to zero gravity (e.g. to behave like in outer space) without having to change the gravity of the whole physics world?
Beta Was this translation helpful? Give feedback.
All reactions