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
IamKraZ
(IamKraZ)
September 19, 2017, 7:45pm
2
This is great, just what I was looking for. Thank you.
BrockyL
(BrockyL)
November 3, 2017, 12:01pm
3
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.
P1r0d0x
(P1r0d0x)
December 20, 2017, 8:58am
4
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
P1r0d0x
(P1r0d0x)
December 20, 2017, 10:20am
6
BluePrintRandom:
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.
IamKraZ
(IamKraZ)
May 8, 2018, 5:22pm
7
@P1r0d0x and @BluePrintRandom Please add me to that private message.
Mauzz
(Mauzz)
May 12, 2018, 5:15am
8
is beautiful to learn mor BGE, thanks a lot