Space game


A simple experiment with gravity in the Blender game engine.

I’ve used only 5 lines of code (python) to realistically simulate gravity between planets and space ships. Planets are orbitting the sun, moons are orbitting the planets and you can get your ship to orbit a planet or moon if you’re very skilled! 😛

d = ship.position - own.position
g = 1
m = own.mass
f = g*m*ship.mass/d.magnitude**2*(d/d.magnitude)*30