Gravity fields in BGE

I’ve been Googling it but none of it solves my problem. I need if I can create an empty that has gravity on it, and if so how. It will affect every “loose” (i.e. dynamic, rigid bodies) item in the world, without the default gravity of BGE. Help!

Moved from “Game Engine Resources” to “Game Engine Support and Discussion”

Well, you would use Python to get a list of the game objects that are within range of the field object, and then apply a pull towards the field’s center. There’s already scripts and resources for planetary gravity, which sounds pretty similar to your question, except that there’s no planet. You should be able to modify the script for your needs.

Point Gravity based on collision with a ghost static

for repulsion, flip the force value,

(also has ability to align magnetics etc with torque and facing )

uses “Wrectified” grab and move

mit 3.0 cc


RockSMash.blend (503 KB)

Note this will work with gravity off as well,

so collison with any object with the property “Hit”

like the object added from layer 2 - induces gravity to the center of that item


pointGrav (1).blend (515 KB)

This is a topic that has interested me too some time ago. But I never tried it!
So, now I have! :slight_smile:

Here is what I came up with. You can duplicate the gravity fields! Create as much as you want.
When the gravity field is initialized it loops once through all objects and checks if objects have a game property “gravityObject”. If so the will be appended to a list. This list is looped through later on so not all Scene Objects have to be looped through!

The gravity field checks the distance to the objects and applies a set force dependend on the distance to the object.
You can customize the force and the forceRange via the game properties on each forcefield object. The Force fields can be moved with the arrow keys.

I hope this helps you! You can use it as you wish! All others of course too!

gravityField.blend (570 KB)

ndee, that is exactly what I needed. Thanks a lot that is beautiful!

Nice one, ndee!
Thank you, very much, for sharing!

nice! :slight_smile: Happy this helps you!
You’re welcome!