Let The Games Begin - I give to you 'Gravity Tools'

Here is a system to enable all sorts of bge games using gravity

if a ghost object has the property ‘Grav’ and it’s a string if the string is

“Lin” = Linear gravity using the collided objects Z axis

“ArcIn” = Gravity pointed to the origin of the object

“ArcOut” = Gravity pointed away from the origin of the object

Attachments

BPRUniversalGravityForMapMaking.blend (769 KB)

2 Likes

This is great, just what I was looking for. Thank you.

I’d like to see the possibilities of gravity pointed out by a common course, Now that would be a challenge. Like a tool to supply routes and speed’s for a given destination through an asteroid field.

Hi, it’s really awesome you’ve shared this! Just wondering ( as i’m a complete noob in python ) what needs to be changed in your code for the “player” not be moved around the object with “gravity” on it’s own, but to move with, lets just say “WASD” and not fall off

to redo this, I would use points in space, and have objects average force vectors on the points in space creating a table of gravity,

all other objects just look up their grid positions and average those vectors.

table = [ [0,0], [-1,0],[-1,1],[-1,-1],[1,0],[1,1],[1,-1],[0,1],[0,-1] ]
pos = agent.worldPosition
pos = Vector([round(pos.x),round(pos.y),0])

for offset in table:
    position = pos+agent.worldOrientation*pos
    key = (round(position.x),round(position.y),0)
    if key in gravity_dict:
         vect = gravity_dict[key]

this way we can have conflicting gravity shapes etc and objects not near the player don’t effect look up time

If you could go into private messages for this matter I would be greatful as i don’t want to flood your thread.

@P1r0d0x and @BluePrintRandom Please add me to that private message.

is beautiful to learn mor BGE, thanks a lot