Search code examples
game-enginegame-physicsblenderbulletphysics

How to change gravity axis/direction in Blender


I am making a videogame in Blender Game Engline, and want to be able to adjust the direction gravity pulls objects. I can change scene Z gravity in a script, but that's one-dimensional along the Z axis.

I would be fine with the ability to set X, Y, and Z gravity, or an easy way to make everything rotate at the same time around the origin (or an arbitrary point).

I could also build a system if I could have a plane exert gravity or a force field and have it rotate around the center at a set distance (the entire gameworld is encased in a sphere).

Basically, I want to be able to, from a python script, cause a force on all dynamic objects, automatically and without . How can I do this?


Solution

  • I think you're looking for bge.constraints.setGravity(x, y, z) To set the gravity.

    and this one: bge.logic.getCurrentScene().gravity to get the actual gravity. According to this you should calculate the ideal rotation for your objects