Gamasutra dev article on Super Mario Galaxy's physics/gravity system

Farid

Artist formely known as Vysez
Veteran
Supporter
http://www.gamasutra.com/view/feature/3593/games_demystified_super_mario_.php

Normally, gravity is calculated as a force between two objects that is directly proportional to the product of their respective masses and inversely proportional to the square of the distance from the objects' centers.

Force of Gravity = Gravitational Constant * ( ( mass1 * mass2 ) / distance2)

To simplify, gravity follows the inverse square law.

Intensity of Gravity = 1 / Distance2

This means that as an object moves closer to a planet, the gravity between them increases exponentially. Conversely, as an object moves away from a planet the gravity between them weakens very quickly.

Traditionally, the force of gravity is applied using the radius of the more massive body. For instance, if we were to calculate the gravity holding a person to Earth we'd plug the Earth's radius into the above equation. Additionally, if the mass is great enough to hold a person down, the celestial body will be round. This is where reality and Super Mario Galaxy differ.

In Galaxy, players are pulled toward each and every arbitrarily shaped planetoid they encounter. At this point all real world physics equations break down and tell us nothing about the gravity in the game, which as in most cases is a trick. Much like the magicians in The Prestige, game developers are always attempting to one up each other with new tricks. As we all know, Nintendo stole the show with its latest.

To accomplish this "trick", the developers use the surface normals of whatever planetoid Mario inhabits to keep him running and jumping happily along. This is how gravity is distributed through completely irregular bodies. A surface normal is a ray or unit vector that runs perpendicular to a plane.

In the illustration above we can see an arrow pointing up from a plane, the arrow represents the surface normal of a plane that points straight up. If we're using a Y-up right handed coordinate system, that normal would be a (0, 1, 0) which means it's not pointing along the x or z axes at all and that the full length of the vector is all in the up direction.

A unit vector always has a length of 1, which is then distributed amongst the x, y, and z directions. The longer one direction is the shorter the others must become.

Don't forget to check out the stick figure programmer's artwork in the second page.
 
Nice article, good insight in how they manage gravity, but their physical explainations make my stomach bleed.

Traditionally, the force of gravity is applied using the radius of the more massive body. For instance, if we were to calculate the gravity holding a person to Earth we'd plug the Earth's radius into the above equation. Additionally, if the mass is great enough to hold a person down, the celestial body will be round. This is where reality and Super Mario Galaxy differ.

In Galaxy, players are pulled toward each and every arbitrarily shaped planetoid they encounter. At this point all real world physics equations break down

That's not even inaccurate, just flat out wrong.
 
It's just a game StefanS. Think the writer just wanted to explain how the "gravity" (if you can call it that) system works. Basing it off the surface normals is the easiest way to do it by far.
 
How is it flat-out wrong? If a celestial body is large enough to have a significant enough gravitational field to make it very difficult to reach escape velocity, it's almost always round due to it taking on an energy-minimizing shape. And on an arbitrarily shaped body, you're most certainly not pulled toward the closest surface. Just try walking up a cliff face some time.
 
How is it flat-out wrong? If a celestial body is large enough to have a significant enough gravitational field to make it very difficult to reach escape velocity, it's almost always round due to it taking on an energy-minimizing shape. And on an arbitrarily shaped body, you're most certainly not pulled toward the closest surface. Just try walking up a cliff face some time.

What about a giant asteroid?
 
What about a giant asteroid?

Great question!

Vesta is the largest (non-spherical) asteroid in the asteroid belt
(between Mars and Jupiter), and it's gravity is only 2% that of
Earth's, and about one-eighth that of the Moon's. If you've seen
astronauts walking in the moon, imagine them bouncing eight times
higher and taking eight times longer to come down from each
bounce.

When an asteroid becomes big enough such that it's own gravity makes
it spherical, it's now classified as a dwarf planet. Ceres is the
only such dwarf planet in the asteroid belt, having a mass about four
times that of Vesta. However, Ceres' gravity is still only bit more
than Vesta's--about 3% that of Earth's. You still couldn't walk on it
like the characters in Super Mario Galaxy. That said, I'm sure Mario
Galaxy is a better game for its liberal interpretation of physics,
unlike, say, the movie Armageddon, which was definitely worse for its
gratuitously flawed physics. :)

BTW, it bugs me that the Gamasutra article refers to gravity as being
"exponential" in the distance from its source. It's not exponential,
it's polynomial; specifically, it's inversely proportional to the
square of the distance, exactly as the equation 1/r^2 says. An
exponential relationship would be 1/2^r, that is, 2 to the rth power,
not r to the 2nd power. Sorry, pet peeve of mine. :)
 
And on an arbitrarily shaped body, you're most certainly not pulled toward the closest surface. Just try walking up a cliff face some time.
Actually you are. It's just that the force pulling you is relative to other gravitational forces from the same body. The cliff-face does exert a pull enabling you to walk up it - it's just that that pull is insignificant relative to the pull directed to the Earth's gravitational centre. An historic scientist, forget who, used the gravitational pull of a mountain to estimate the mass of the Earth. Or something like that. IIRC he measured the displacement from vertical of a suspended mass with the mass of the mountain causing a gravitational pull lateral to the Earth's pull.
 
BTW, it bugs me that the Gamasutra article refers to gravity as being "exponential" in the distance from its source.

That bugged me far more than anything else.

Actually you are. It's just that the force pulling you is relative to other gravitational forces from the same body.

Shifty, you've known me long enough through these boards to realize that I am not so ignorant about physics that I think that a particle of matter doesn't have a gravitational field should a free body not be moving in its direction (keeping in character, you ought to jump in now to lecture me that no body can be truly "free" due to choose-your-phenomenon). What I meant by "pulled toward" is transparently clear to anyone not out to score points by picking apart my words. Your lesson in freshman physics, while perhaps informative to any high schoolers on the board, was completely unnecessary.

But since you feel it necessary to scold anyone for not giving detailed technical explanations, I will explain what I mean by "pulled toward:"

Given a mass M1 in close proximity to an irregular mass M2, the net force on M1 cannot be found using the usual spherical body approximation. It is instead an integral whose integrand is the usual gravitational law, and whose region of integration is determined by the geometry of the object itself. The result of the integral is a net force vector F. In the case of a spherical body approximation, F is in the direction of the normal to the nearest surface of M2. However, in the case of two irregular bodies in close proximity, it is not necessarily this vector. Thus the body M1 will exhibit a net acceleration that is not necessarily in the direction of the nearest surface normal, i.e. it is not "pulled toward" that surface.

I could be more specific, but then I'd just be wordy. Look up the formula for the integral yourself.
 
Last edited by a moderator:
I wasn't 'scolding' at all, only informing in case you didn't know. Which you do. No harm done, or meant, and even if you didn't need to be informed (and indeed no-one needs to be informed!) it might be useful for someone to read, so there's no harm in writing it for general benefit to readers.
 
Why are you guys bringing science into a fictional game's world that already doesn't simulate true gravitational physics to any realistic degree?
 
Back
Top