Scene: gravity

gravity
  • get/set the world gravity

Type:

  • float list [ gx, gy, gz ]

gx:

  • force of gravity on the world x-axis
  • Type:  float number
gy:
  • force of gravity on the world y-axis
  • Type:  float number
gz:
  • force of gravity on the world z-axis
  • Type:  float number
Note:
  • Default gravity = [ 0.0, 0.0, -9.8 ]
Sample Code

################## get the world gravity
 
# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get the world gravity
grav = scene.gravity

Sample Code

################## set the world gravity
 
# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# set the world gravity to half
scene.gravity = [ 0.0, 0.0, -4.9 ]