It’s a’ me, a-Mario! “Intuitive” vs. “Real” physics in games

Over the past decade, increases in CPU speed and the offloading of computationally intensive graphics operations to the GPU has left room for game developers to not only make a world that looks real, but acts that way as well. Case in point: physics in games. While most commercial games from 1995 might have had only rudimentary collision detection, many games today, such as popular hits like Half Life 2 and Halo 3, implement complex physics systems that involve a number of different constraints and solvers to create the impression of gravity, friction, angular momentum, springs, and other Newtonian mechanics components. Simulating these quantities requires, at the very least, an integrator such as RK4 as we discussed in class to find the velocity and position of each body in the game.

In the case of gravity, most games assume a constant force direction of -y, which makes sense when you’re a regular person on Earth. But what if “down” is variable? That was the case in the recently released “Super Mario Galaxy”.  This article on Gamasutra explained how the creators of this game decided to “model” reality. While the final system was certainly more involved, the basic idea was the following:

  (image from article)

Each surface in the game has a vector associated with it called the normal; it’s perpendicular to the plane of the surface. The direction of gravity is found by locating the nearest surface underneath Mario, then setting gravity’s direction to be the negative of the normal direction. The article describes the algorithm in more detail, but finding the “nearest” surface is found by casting a ray from the Mario’s “center” to the center of the planet to which he is closest. The force appears to change smoothly because the normals of the planet don’t jump suddenly; they vary only slightly from one polygon to the next. In the linked demo in the article, the smoothness of motion added by using additional polygons is apparent as you move to higher-polygon planets.

Note, also, that if you move closer to a planet other than your current planet, then that planet is used to simulate gravity instead. You can find a similar concept in 2D in the free game Frozzd, which also uses variable gravity direction based on the closest planet. The “snap” as you move from one planet to another is more apparent in this game.

These examples illustrate an important point when modeling physics in games. Game simulations are both similar and divergent from “real” simulations (those used for scientific and engineering purposes). Both use a system which requires solving constraints in order to move a system from time t-n to t-n_plus_one, and both may use a simplified model of reality in order to run that system. However, whereas an engineering system certainly would not ignore the gravity from any nearby bodies nor would it assume gravity is defined by whatever ground is closest to you (say, if you were an interplanetary rocket navigating the asteroid belt), this perversion of physics works in games because it’s “intuitive”. It’s what the average person expects based on their daily interactions. As games use increasingly sophisticated physics models, their goal may not always be perfect simulation!

References:
Gamasutra’s Games Demystified: http://www.gamasutra.com/view/feature/3593/games_demystified_super_mario_.php
Frozzed: http://www.yoyogames.com/games/launch/20523

Posted in Topics: Uncategorized

Jump down to leave a comment.

Leave a Comment

You must be logged in to post a comment.



* You can follow any responses to this entry through the RSS 2.0 feed.