Newton's Laws in Video Games

Posted by Billy on 13 June, 2015 at 9:44PM

Tags: physics, video games, technical, other, newton

Newton's Laws in Video Games

As computer hardware technology has gotten faster and more advanced, so too has the entertainment software running on it. I am speaking of course, of video games. Increasingly important in today’s video games is the use of physics. In order to become immersed in a video game, players often expect the game world to react in a realistic way, which means physics calculations. In real life, we explain how objects move and interact using Sir Isaac Newton’s three laws of motion. In video games, we also apply these same laws, but in a video game context. Indeed, the process of applying Newton’s laws in a video games is often called a “simulation”, often through the use of a special sub-system called a “physics engine”.

Before we can begin applying Newton’s three laws to video games, we should be clear on what exactly they are. Newton’s first law of motion states “an object will remain at rest or in uniform motion with constant velocity unless acted on by a net external force.” This means that an object will not move unless the net force acts upon it. “Net force” is important, because it means that if two forces are pushing on either side of an object with the same amount of force, the object will not move. Newton’s second law states “an object is accelerated whenever a net external force acts on it. The net force equals the object’s mass times its acceleration.” This law delves into the relationship between force and acceleration, providing the formula F = ma, or force equals mass times acceleration. This formula is extremely useful in video games. Newton’s third and final law we’ll be discussing states “force always come in pairs: when one object exerts a force on a second object, the second object exerts an equal an oppositely directed force on the first.” This law is usually simplified as “every action as an equal and opposite reaction.”  This law is especially useful for video games, as object interaction is a huge part of video games. There are many other physical laws governing things like light and fluids, but they are out of the scope of this article.

Obviously, video games are not “real life”, which is what the physical laws apply to. For the purposes of video games, things have to be adapted. Unlike real life, when two objects touch each other, the program has to detect when such effects occur, and react accordingly. This is done with an operation called “collision detection”, which can take a lot of time for the machine to process for complex shapes. For this purpose, objects are usually broken into pieces using much simpler shapes (often squares and triangles), which increases processing speed. Another factor to consider is that the only predefined units for video games are the pixels of the screen. The output to the screen for a computer or video game console is a giant grid of colored squares called pixels. Pixels are rarely used for width or length used in video game physics calculations; video game engines often define their own units, often just called meters, which are then scaled to match the pixel output. Video games are much like movies, they run in a cycle and update the screen with a new video frame a certain amount of times per second. For video games, this is usually thirty or sixty frames per second, which can also be expressed as 30Hz or 60Hz. Game physics will often measure time in seconds, or in “tics” – a custom time step that more closely matches the frame-rate of the game.  Objects in the game will have mass (and weight, if the game employs gravity), which will accurately affect how the object moves. And finally, all objects in a 3D game will have a Cartesian coordinate position (X, Y, Z), and a rotation (pitch, yaw, roll). In a two dimensional game, they will only have X, Y and pitch.

However, most video games are not simply simulations of physics, but a game involving the use of physics. As a result, games employ physics into their game mechanics, or gameplay rules. There’s no better examples of this than Half Life 2 and Angry Birds. Half Life 2’s main physics based mechanic relies on a weapon called the “Gravity Gun”, that allows the player to pick up solid objects, and accelerate them rapidly towards enemies. Newton’s laws are definitely in play: The gravity gun cannot pick up objects that have too much mass (for example, a car), meaning the net force of the gravity gun’s pull isn’t enough to overcome its mass, and so acceleration remains zero. In addition, objects that can be picked up and hurled do more numerical damage to enemies based on how much mass they contain. Objects that have less mass will fly much faster, but do less damage; the acceleration of the object is increased due to the smaller mass.

Angry Birds, in contrast, uses Newton’s laws for gameplay in a more direct fashion. The goal of the game is to use a slingshot to launch birds into a tower of stacked blocks that has green pigs resting on it. Once all the pigs have been knocked down from their resting place, you win the round. Firstly, to launch the bird, you pull back on a slingshot that the bird sits in. When you pull back on the slingshot, you build potential energy, which is then applied as a force on the bird once you release it. The pigs don’t move until a force is applied on them from the bird. Often times this will be indirect, as you will hit the blocks which will then hit the pig. Gravitational force is always in effect which, naturally, causes the pigs to fall off of the blocks, but also causes the birds to move in a parabola-like arc. As in real life, the gravitational force causes the bird’s upward vertical motion to slow down and eventually be pulled downwards. In video games, this would be expressed as the bird’s Y-velocity going from positive to negative, or vice-versa depending on implementation.

Physics engines in modern video games are nearly ubiquitous. In the past, games often had very simplified physics models, but they were nowhere near as realistic as in games today. In addition to allowing the game’s environment to react realistically, they allow for some interesting gameplay mechanics. Newton’s laws provide an easy way to implement realistic physics into a video game. Computer technology is now powerful enough to run these calculations in real time with ease, and video games have taken great advantage. A video game, boiled down to its most simple form, is just a large set of rules, and all you have to do is make sure your game always follows the rules of Newton.

Sources