Make gravity force opposite normal

Post Reply
lamxuyen
Posts: 2
Joined: Wed Sep 05, 2018 8:25 am

Make gravity force opposite normal

Post by lamxuyen » Fri Sep 07, 2018 8:32 am

Hello there. I'm new to Bullet and my goal isn't that standart, that's why i'm here.

Guys, i'm planning to make a game like Spore with generated planet. So there's a question: how do i make gravity force point opposite the direction of the normal in current objects collision?
Thanks for your patience. :wink:

User avatar
drleviathan
Posts: 455
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Make gravity force opposite normal

Post by drleviathan » Fri Sep 07, 2018 3:32 pm

Do you mean: "How to implement a planet's gravitational field in Bullet?" ?

If so, here is some info:

Bullet has a World gravity setting (btDiscreteDynamicsWorld::setGravity()) but it is uniform.

You can override the World gravity on a per-object basis: btRigidBody::setGravity().

For a radial gravity field you would need update the gravity of each dynamic body every frame. This could be done in a few ways but the one that makes the most sense would be: derive a custom class called MyDynamicsWorld from btDiscreteDynamicsWorld and override btDiscreteDynamicsWorld::applyGravity() to do your bidding.

If you really want to set an object's gravity based on the normal of an instantaneous collision (which sounds like a Bad Idea to me) then perhaps you could elaborate on what you really want to do.

Post Reply