 # Bullet: set gravity to 25+ [ANSWERED]

maybe in python? How?

I’m not sure that there is a way to do that, however you can make the gravity look higher if you just make everything in your game smaller.

awsome, thanks. Even though that’s not what i asked, you helped me solve the problem. PS: Please change the title to “set gravity above 25 in bullet?[ANSWERED]”.

Lol, even though it says solved… I’ll answer the initial question since others might dig it up in the future. You can set gravity higher than 25 with python.

But be warned that too high of a gravity might not trigger collisions with objects. It’ll just go through. I used 50 because anything over that for me the cube would go through the plane.

``````
import GameLogic as g

g.setGravity([0,0,-50])

``````

Jason Lin

# use one (Z-axis) component of the vectors to calc gravity

import Blender
from Blender import *
from math import *
import GameLogic

zero_vector = [0.0,0.0,0.0]

# set gravity-point to origin

gravity_point = zero_vector

g = GameLogic

# So that we can use our gravity script below on a frame by frame basis

c = g.getCurrentController()
o = c.getOwner()

mass = 200.0
#mass = o.getMass()
pos = o.getPosition()

G = 160.81

# subtract pos from gravity-point

gv = [gravity_point - pos, gravity_point - pos, gravity_point - pos]

# calc absolute distance ( based on C^2 = A^2 + B^2 )

d = sqrt((gv * gv) + (gv * gv) + (gv * gv))

# calc force of gravity

f = G * mass/(d*d)

# gravity vector

gv = [(f/d)*gv,(f/d)*gv,(f/d)*gv]

# “gvector” is a motion actuator logic brick for this object

fv = c.getActuator(“gvector”)

# set the force vector of gravity for this object

fv.setForce(gv,gv,gv,False)

# Activate it

i dont really get all the maths but what does that do? i think it makes the object go towards a certin point that is the center of gravity? or what does it do

It looks like it makes gravity similar to Super Mario Galaxy: instead of falling towards a plane in the -Z direction, things “fall” towards a point.

cool thats what i thought

could be usefull

Yup, This[thinkofwhy’s code] is a great way to model physical explosions!!

what set it to minus gravity by using
fv.setForce(-gv,-gv,-gv,False)?

i didnt think of that good idea i was using a sphere that expanded and pushed things outwards

That gravity.py code isn’t mine. I found it in this forum somewhere and changed it a bit for my purposes (customized).

So, when I saw this thread I quickly ripped it out to post it here. You should experiment with it and change it for your own uses.

It’s a very useful and powerful bit of code. The gravity.py script works great, but I can’t get the objects affected by it to collide with the sphere (planet) I have put at the origin for them to be pulled to. They collide with each other there, but just form a weird mass of objects pulled toward the center. If I remove the planet, all the objects get flung off into deep space once they reach the origin, though.