Found in platformers like Mario Galaxy and Sonic Lost World; dynamic, planetoid gravity allows for unique gameplay opportunities where the basics of “up”, “down”, and “forward” are constantly being remixed in exciting ways. Simple shapes like a sphere are easy to visualize and implement. However, accommodating uniquely shaped planetoids presents a challenge to define the direction characters should experience gravitational forces.
Link to GitHub Project
Objects & Orbits
On a basic level, there must be objects that experience gravity and objects with gravity.
The class, Gravity Controller, keeps track of nearby gravitational forces and applies forces to a character.
An abstract class, Gravity Orbit, defines gravity sources, registers them with the Controller, and can be overridden to define the gravity direction for each unique object.
Unique Orbits
By creating several child classes of Gravity Orbit, we can create unique gravity fields that will pull characters into the surface of basic shapes.
These include: Sphere, Cylinder, Disc, and Planar.
With a single toggle, these gravity fields can either pull object towards them, or repel them.
Results




