As all good stories are, this one is set in space.

Link to project files

This (vaguely) Marble Madness inspired sketch explores physics and motion in 3 dimensions. The objective of the game is to roll around and hop between small, close planets in search of missing parts for your broken spaceship.

At the core of the sketch is a gravity system that works based on the well known F=G(M1.M2/r^2) equation. The force applied to the player’s rigidbody is the sum of G(Mn)/rn^2 where:

  • G = some constant that has been tweaked for the size of the world
  • n = each planet (this function is an iterator)
  • M = an adjustable ‘mass’ for each planet
  • r = the Vector3 distance between the player and each planet

Since gravity works on an inverse square law (the result of dividing by r^2), being closer to a planet means that its influence is quadratically higher. When you’re near a planet you are ‘captured’ by that planet’s gravity, but when you’re in space the forces are weaker and relatively more competitive.