Our Properties: Gamasutra GameCareerGuide IndieGames Indie Royale GDC IGF Game Developer Magazine GAO
My Message close
Contents
Games Demystified: Super Mario Galaxy
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
February 10, 2012
 
Road to the IGF: Lucky Frame's Pugs Luv Beats
 
Analyst questions validity of unusual January NPD results [3]
 
DICE 2012: Blizzard's Pearce on World Of Warcraft's launch hangover
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
February 10, 2012
 
Sony Computer Entertainment America LLC
Audio Tools Engineer
 
Sony Computer Entertainment America LLC
World Wide Studios Technical Product Manager
 
Sony Computer Entertainment America LLC
Senior Software Application Engineer
 
Sony Computer Entertainment America LLC
Senior Gamer Insights Specialist
 
High 5 Games
Technical Artist
 
Airtight Games
Art Director
spacer
Latest Features
spacer View All spacer
 
February 10, 2012
 
arrow Principles of an Indie Game Bottom Feeder [19]
 
arrow Postmortem: CyberConnect 2's Solatorobo: Red the Hunter [1]
 
arrow Jerked Around by the Magic Circle - Clearing the Air Ten Years Later [39]
 
arrow Building the World of Reckoning [4]
 
arrow SPONSORED FEATURE: TwitchTV - How to Build Community Around Your Game in 2012 [13]
 
arrow Happy Action, Happy Developer: Tim Schafer on Reimagining Double Fine [9]
 
arrow Building an iOS Hit: Phase 1 [11]
 
arrow Postmortem: Appy Entertainment's SpellCraft School of Magic [5]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
February 10, 2012
 
Audio Passes: Success Through Layering
 
What the current RPG can learn from Diablo 1
 
Double Fine's Kickstarter Windfall: Will Patronage Supplant Traditional Game Publishing? [5]
 
The Principles of Game Monetization
 
Did DoubleFine Just break the publishing model for good? [13]
spacer
About
spacer Editor-In-Chief/News Director:
Kris Graft
Features Director:
Christian Nutt
Senior Contributing Editor:
Brandon Sheffield
News Editors:
Frank Cifaldi, Tom Curtis, Mike Rose, Eric Caoili, Kris Graft
Editors-At-Large:
Leigh Alexander, Chris Morris
Advertising:
Jennifer Sulik
Recruitment:
Gina Gross
 
Feature Submissions
 
Comment Guidelines
Sponsor
Features
  Games Demystified: Super Mario Galaxy
by Jeremy Alessi [Game Design, Programming, Console]
10 comments Share on Twitter Share on Facebook RSS
 
 
March 27, 2008 Article Start Page 1 of 4 Next
 

Welcome to the first article in a new Gamasutra series called Games Demystified. In this series I'll be deconstructing games with unique or distinguishing mechanics that may have left some folks scratching their heads, including reproducing effects with code samples, examining -- just how did they accomplish that? The first game we'll be covering is Super Mario Galaxy for the Nintendo Wii.

Upon release, Super Mario Galaxy enchanted the gaming community because it allowed gamers to walk upside down and inside out -- all while feeling completely intuitive. Especially geeky message boards and blogs have lit up with people attempting to apply real-world physics equations for gravity to each of the game's tiny planetoids.


Obviously, real world physics have a place in today's games. However, they take a backseat to psychology when it comes to making real world gameplay. In reality, mass distorts the fabric of time and space causing gravity, the force that keeps us stuck to Earth.

People such as Isaac Newton have studied and derived a great deal about gravity, but no one actually knows the true mechanics behind the force. The important thing for the game is that we expect to get pulled toward planets -- and in fact, Mario does get pulled to each and every strangely shaped planetoid in the game.

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 dramatically due to the exponential effect applied by distance. 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.

 
Article Start Page 1 of 4 Next
 
Comments

Soren Nowak
profile image
Funny to see this article now. Three weeks ago we gave up on getting this to work in a HL2 Source mod. We ended up making a flat world instead (se my website link for the mod profile page on moddb.com)

Dan Mitchell
profile image
Excellent article. I cannot wait till the next on Very informative, and educational. I love seeing articles like this, since it helps cut down time on dev time/ research thus allowing others sections of the dev project more time, allowing for even more innovation.

Giuseppe Navarria
profile image
Nice article so far, maybe the tecnique you explained is a bit rought, for example movement will be smoother with normals interpolation, also a simple raycast will lead you in a sea of gameplay glitches...
PS Next time, set your example NOT at 640x480 fullscreen, or it will crash for users without a prehistoric monitor supporting that low resolution, I had to download the source and recompile it running on a window to see your stuff!

Frank Plumbo
profile image
I used a technique very similar to this in Shockwave3D a couple of years back to create my freeware game Microbop (http://gigaplay.com/microbop).

If it can work in Shockwave3D, it can work anywhere! ;-)


Robert Dowling
profile image
This was a great little read. I'm no engineer myself, but it may cut a little research time off my coding partner's schedule.

Andrew Williams
profile image
Great article, this looks like its going to be a great series. On a side note, If anyone is familiar with Sonic Adventure 2 battle, or just Sonic Adventure 2, the space levels in that game seemed to use a very similar technique to what we see in galaxy, however I do believe that to jump from planet to planet required a cannon of sorts. Anyway, great article, hope to see another soon.

paul grenfell
profile image
Good article. Looking forwards to more in the series :)

Now check out Serious Sam's gravity handling. They did it using zones (defined in the level editor) and it works very well. It is also easier to implement well since you don't need to worry about any smoothing. I suspect that SMG may well have used a hybrid of these two approaches.

Jose Teran
profile image
Great article; a nice approach for understanding the world of physics in games.

This will help us to acquire some more basic knowledge about gravity and it's use on games, which are very demanding right now.

Keep up the good work, and I want to read the next ones.

Marc Melvin
profile image
I am a little annoyed that I'm just coming across this article today, but I'm also relieved that my method for doing similar logic in a game I was building for Dream.Build.Play using XNA is right on target with the logic used by a previously successful game title.

The only problem I ran into using this method was that snapping an object instantly to a new surface normal sometimes caused its ray to hit the polygon that it was previously using to calculate its up vector (when moving slowly along a "downward" slope, that is). I ended up scrapping this method because of the jittery back and forth effect that it was causing, eventually spiraling the object out of control into oblivion... maybe if I had LERPed the rotation slowly as mentioned in this article, I wouldn't have had the problems that I did.

Oh well... live and learn. Good article! :)

Tom nguyent
profile image

I love mario brother, I used to play all day when i was a kid...missed them :)


none
 
Comment:
 




UBM Techweb
Game Network
Game Developers Conference | GDC Europe | GDC Online | GDC China | Gamasutra | Game Developer Magazine | Game Advertising Online
Game Career Guide | Independent Games Festival | Indie Royale | IndieGames

Other UBM TechWeb Networks
Business Technology | Business Technology Events | Telecommunications & Communications Providers

Privacy Policy | Terms of Service | Contact Us | Copyright © UBM TechWeb, All Rights Reserved.