Relative gravity

I am trying to make a 3D Maze like game where i want the players not only to walk round corners but also horisons to get to the end. So the main question is: how do i set the central of gravity in the middle of the stage so the players won´t fall of the stage?

As I understand it, to change the gravity of all objects while in the game you really need to use python, however…

Gravity is just a constant force in one direction and you can create forces with a motion actuator sooo… I’m guessing you could do something like:

  1. Remove the default gravity in the BGE (f5->World Buttons->Mist/Stars/Physics tab/ change Grav to 0)
  2. put an empty to where you want the “center of gravity” to be
  3. Have your character track the empty (so their feet point to it) (sensor:always,actuator:edit object edit/track to)
  4. Have a constant force moving your character “down” on their local axis with a motion actuator

There are a couple of challenges with doing it this way though, mainly to do with “flying off the planet” and if your map is anything but round.

In the blend file I just set Linear Velovity (linV) for the gravity to 0 (well, .001) when moving so you don’t fly off when running. This works fine here, but would cause problems if you wanted to “jump”. If any of the more experienced Blendheads could offer an idea I’d love to hear it. :slight_smile:

The other problem is that this assumes you’re walking on something round. Try scaling the “world” in one axis and your charcter starts finding it hard to walk near the edges and toppling over. :frowning:

To make an area where the gravity is different, you can do the following:

  • Leave the gravity in the World Buttons Window to 9.8
  • Make sure “actor” is turned on in the Logic Window of your character
  • Create an empty and put it in the area you want to change the gravity of
  • Add a Near Sensor to the empty, (increase Dist and Reset to make the Area larger)
  • Make the Near Sensor only sense your character, by using properties
  • Connect the Near Sensor of the empty to a Motion Actuator of your character
  • Set the Z force to a force, so that it ‘makes’ the gravity 0. (You can find out what this force should be by multiplying the mass of your character with the gravity, for example if the mass of your character is 2, and the gravity is set to 9.8, the Z force in the Motion Actuator should be 19.6)
  • Now you created an Area with 0 gravity (well not really, but it looks like the gravity is 0)
  • If you want to have gravity in, for example, the X direction, set the X force to the same force you used for the Z force

Now you have an area with a different gravity direction.