🤑 Indie game store🙌 Free games😂 Fun games😨 Horror games
👷 Game development🎨 Assets📚 Comics
🎉 Sales🎁 Bundles

Applying gravity to a conn.js body

A topic by sheep_knight created 1 year ago Views: 155 Replies: 2
Viewing posts 1 to 3

Hello !

I wanted to make that a cannon body would fall while in mid-air, by using gravity. I found the world.gravity.set method. That doesn't do anything, so here is the code, if you see something that I did wrong.

awake() {

let world = new CANNON.World();

world.gravity.set(0,-9.8,0);

}

PS : I already looked at the doc, but didn't found anything :'(

thanks to at least read my post:)

Nevermind !I finally found a way :

First, I Set the world in the class, not in the awake method.

Second : use "this.world.step(1/60);" in your update method so the world will apply the gravity correctly every 60 frames per second.

So yeah...

Have a nice day though !

Or just do :

Sup.Cannon.getWorld().gravity.set(0,-10,0);