Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bge
- scene = bge.logic.getCurrentScene()
- own = bge.logic.getCurrentController().owner
- G = 1
- for obj in scene.objects:
- if obj != own:
- vec = obj.worldPosition - own.worldPosition
- F = G*obj.mass*own.mass / vec.length**2 # F = G*m1*m2 / r^2
- own.applyForce(F*vec.normalized()) # apply force in direction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement