Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import bge
  2.  
  3. scene = bge.logic.getCurrentScene()
  4. own = bge.logic.getCurrentController().owner
  5. G = 1
  6. for obj in scene.objects:
  7.     if obj != own:
  8.         vec = obj.worldPosition - own.worldPosition
  9.         F = G*obj.mass*own.mass / vec.length**2  # F = G*m1*m2 / r^2
  10.         own.applyForce(F*vec.normalized()) # apply force in direction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement