Motor! or What is game physics



When creating a game, developers have to find a balance not only in mechanics, but also in physics. Realism or arcade? In general, someone like that. The main thing is fan and pleasure. It is necessary to create the fundamental laws of your world, and explain that the ability to walk on the ceiling is a mechanic, not a bug.

How complicated game physics should be, what kinds of games there are and what tricks developers go to when implementing them - translated under cut.

Physics in video games is often taken for granted. If the character jumps, he is obliged to land, and not fly into space (although with a fairly long game in Skyrim, this can still happen). We expect that the objects in the game will behave as in life (we donโ€™t take bugs into account).

Programming physics can come down to one or two methods with a couple of lines of code. Or maybe a complex system with a separate physical engine (for example, Havok or PhysX ) with millions of lines of code. Regardless of complexity, game physics is divided into two categories: solid state physics and soft body physics.



Solid state physics is needed in most 2D and 3D games. Soft-body physics describes the action of forces on an object that takes various forms (for example, a flag). Displaying a soft body is much more difficult, so this approach is used much less often.

The important role of gaming physics


Game physics serves different purposes, but the most important ones are intuitiveness and fun. If an object behaves unpredictably, it will be difficult to understand the rules of the game.

If the ball in FIFA 20 each time bounced in a random direction, it would be impossible to score a goal. The developers are trying to recreate the rebound of the ball depending on its trajectory, speed and other factors in the real world. For the player to intuitively understand how to handle the ball or other objects. By the way, FIFA 20 has a lot of bad reviews precisely because its physics does not work as fans expected.


Moreover, games are not required to strictly observe the natural laws of nature. The main thing is that the game should be fun, and the implementation of real physical laws can destroy the whole experience. Imagine Grand Theft Auto V with harsh terrestrial physics (but if you really want to, you can put a special mod ). Even a mild accident at high speed would end fatally, kill the pace and atmosphere. Not very fun.


The developer must find the right balance between a fun game and a game with realistic physics. And it often depends on the target audience. A good example is racing.

Many people like Arcade Racing (Need For Speed), in which touching the chipper or a sharp turn weakly affects the control of the machine. Others prefer realistic racing simulators (Gran Turismo).

But even creating simulators, developers are trying to attract a new audience - Gran Turismo relied on photorealism (and to some extent it worked). But in the end, Polyphony Digital added an arcade mode to capture a bigger market.

Solid state physics


Speaking of game physics, we usually mean rigid body physics (RBP). It describes and reproduces the physical laws applicable to solid masses of matter. The ball in FIFA 20 is a solid that is controlled by the physics of the game.

It doesn't matter if we look at 2D titles like Pong or 3D titles like Skyrim - most games have linear solid state physics.



Physics of 2D Games


Take Pong as an example. Two solids (ball and racket) collide again and again. That doesnโ€™t sound very encouraging. The grandfather of video games did not have realistic physics.

First, programmers ignored gravity, friction, and inertia. There was just a ball moving back and forth at a constant speed.
Secondly, the bounce angle of the ball from the racket was not calculated accurately. The ball completely ignores the law of reflection: if rotation and other factors are not taken into account, the angle of incidence of the ball on the surface is equal to the angle of its rebound from it. In Pong, the angle of reflection was determined by how close the ball was to the center of the racket at the time of contact. The original trajectory did not matter. Players could completely change the inertia of the ball, despite the vector of its movement.

The ball trajectory has become more taken into account in later versions and in other similar games. For example, in Breakout. But even there is no realism, otherwise a fun game turns into a boring and difficult one.



Games with artillery were the first to take gravity and resistance into account in their mechanics. Users took turns firing cannonballs, arrows and missiles to destroy the enemyโ€™s base. Such games took into account semi-realistic ballistics, that is - the launch angle, gravity, wind resistance and the original speed. But again, the designers did not seek to do everything as in the real world. Their target audience was ordinary people, not ballistic experts.

The behavior of solids (primarily shells) depended on several forces. In accordance with them, the animations changed. Arrows and rockets are a great example of animating solids in similar games. The plane of the projectile could change during the flight, and the arrow remained straight. Two points on an object in a system of solids will always be at the same distance from each other.

Games like Donkey Kong and Mario Bros. strongly influenced the physics of 3D projects. Mario made friends with the basic physical laws - gravity, momentum and inertia. The jump became the main mechanics and remained in the gaming industry forever.



The bouncing object should fall back. The only question is how high it will rise and how quickly it will fall? And how realistic should gravity be in a game?

If Mario obeyed the real laws of physics, he would never have passed the first level. The balance had to be changed for the sake of fun gameplay and players' expectations.

Further games in the series expanded these boundaries - a double jump appeared. In this franchise, it was first added to Super Mario 64, but had previously been used in Dragon Buster in 1984.

Double jump began to be actively used in platformers (sometimes even too much). And it is still there in many modern projects, including 3D. For example, Devil May Cry and Unreal Tournament.

3D physics


Physics in 3D games is not much different from physics in 2D projects. The calculations are complicated by the third dimension (Z axis) and the fact that objects consist of several solids.

In most 2D games, developers only need to process data from just a few collisions of solids. For example: Mario jumps on Kupu. Mario can touch any part of the Kupa. Depending on the point of contact, either Coop hides in a shell, or Mario loses his life. In any case, we are talking about a single touch.



In 3D games, several solid objects collide simultaneously. In Uncharted, when Drake climbs a rock, the program monitors at least his arms and legs - individual solids. He can bounce and grab the stairs with one hand or two, and the animation will be different.

In 3D games (and some 2D), the limbs of the characters are divided into several solids that are connected by joints. That is, the model of the human hand consists of the forearm and hand, which are connected by the wrist and are attached to the shoulder by the elbow joint. This is described by ragdoll physics (from the English ragdoll - rag doll).


Image: University of California , Riverside

Compounds of solids (joints) are created in the skeletal animation system of the game engine. Each solid must move according to certain rules in order to look realistic. To calculate the movements, programmers use various techniques. The most famous is Featherstone's algorithm , a restrictive approach that prevents limbs from hanging out randomly.

There are other approaches to working with ragdoll: Werle integration (Hitman: Codename 47), inverse kinematics (Halo: Combat Evolved and Half-Life), mixed ragdoll (Uncharted: Drakes Fortune and many others) and procedural animation (Medal of Honor series )



All these techniques are aimed at ensuring that the body does not go limp too quickly and does not fall to the ground, like a rag doll. The motion of solids incorporated into a model is limited, so they behave predictably.

Let me remind you, you always need to find a balance between realism and fun. Even if the game will cheat a little.

Take the Sniper Elite series. In the real world, a shooter must take into account a bunch of variables: wind speed, wind direction, range, target movement, mirage, light source, temperature, pressure and the Coriolis effect .

If Rebellion created an authentic sniper simulator taking into account all the variables, the game would become very difficult. Their ignoring is due not only to the capabilities of modern processors. The average user not only does not want to calculate all these factors during the game, he does not even want to know about them. Itโ€™s more profitable to let the player use the scope and show the bulletโ€™s flight in slow mo.


Call of Duty: Modern Warfare has a level where you need to hit a target from a long distance. The player must take into account the Coriolis effect, as well as the speed and direction of the wind. Some people like this challenge, but I abandoned it.

Racing is another genre that requires a lot of calculations on solids and the forces acting on them. The wheels are in contact with the road surface, the suspension is in contact with the wheels, the cars collide with each other. Still other objects directly or indirectly participate in collisions.

The physical forces acting on cars when turning are usually simplified. Drifting in them is simple, but at the same time quite complicated - players should feel satisfaction.

The Gran Turismo and Assetto Corsa simulators have more realistic forces. For example, Assetto Corsa Competizione (version 1.0.7)uses a five-point tire model. It includes two points on the front edge of the tire, two on the rear and one in the middle - all together act as a combined solid. Points can move and bend in three dimensions, independently responding to external forces and contact with the surface. Additional points significantly increase the number of calculations that the engine performs.


Physical models in 3D titles are much more complex than in 2D. You have to keep track of more variables and common ground. But most of the calculations are linear, so such models are much simpler than soft body models.

Soft body physics


Soft body physics (SBP) describes deformable objects. It is used less often and is greatly reduced in video games due to the huge amount of computing.

Soft bodies are clothing, hair, and accumulations of particles such as smoke or fog. The points of a solid always remain at the same distance from each other. A soft body can deform and move so that the distance between its points will change.

Deformable solids


Soft body movement may be limited. All points of the flag will always remain on the flag, they cannot separate. The range of deviation of points from each other depends on the distance between them on the smoothed flag.

Adjacent points always remain adjacent. Remote points can come nearer, but at the same time they cannot move farther from each other beyond the distance at which they are fixed on the expanded flag.



The number of calculations for the soft body exceeds the capabilities of the CPU and GPU. Therefore, developers simplify and trick. For example, looping animation is used. But such a picture will seem unnatural after some time. It is better not to resort to such a life hack if the object is in the center of attention.

Clothing has almost the same soft-body properties as the flag, but its physics is even more complex. Firstly, because the player will definitely pay attention to her. Secondly, because it is often more dynamic: the player exerts its own influence on it. A great example is Batman's cloak in the Arkham series.


Designers cannot use looped animation on a cloak, because its movement depends on the actions of the player. If the player directs the character to the left, the cloak should shift to the right in order to realistically display the inertia and air resistance.

This is where physical engines come into play. In Batman: Arkham Knight, Rocksteady used APEX Cloth PhysX. This tool allows you to create a mask for bodies displaying clothes, and adjust the parameters of their movement. Depending on the configuration, everything from silk to burlap can be displayed.

To improve performance, you can limit the effects of natural forces on the fabric. For example, the Wind Method can be set to Accurate or Legacy. Partial display ignores small fluctuations, fewer calculations are performed.

Not all points on the fabric need to be considered - they can act in groups. This reduces the number of vertices that need to be processed. However, not all of these groups interact with each other as in a real soft body. They mainly affect only the nearest points, so the number of mathematical calculations is reduced to an acceptable level.

Soft Body Particle Systems


Displaying smoke or clouds is even more difficult. The points of such objects can move nonlinearly relative to each other. Some points can move beyond the figurative boundaries of the object and even form other soft bodies.

Physical engines have significantly improved particle systems in recent years. Look at the welcome screen from Skyrim and how realistic the smoke looks there.


Each particle in the soft body system has a static lifespan. This is the period from the moment of its occurrence to the moment of its disappearance (after some time, the source of particles will create it again). During this period, the point moves with the given parameters.

Consider the smoke from a campfire as an example. Each particle moves upward from the source: nonlinearly, spinning and randomly changing its position in space. So they rise until their lifespan ends, and then they are removed.

Life expectancy affects how naturally a particle system looks. With a long duration, you can create quite realistic smoke from a fire, but this will heavily load the processor. Short - reduces the number of calculations, but the particles will only have time to slightly rise before disappearing.

The smoke in the Skyrim screensaver looks cool, simply because nothing else happens on the screen. The entire power of the processor and video card can be directed to simulate smoke particles with a very long lifespan.



In the game itself, the smoke from the fire does not look so realistic anymore. It is still pretty convincing, but simpler: developers have reduced the time it takes to display particles in a simulation. There are other tricks. For example, overlaying multiple static smoke layers

Soft-body physics is very carefully added to games. Firstly, there is no need for a complete simulation of soft body physics - as a rule, it is needed only for aesthetics. Secondly, the exact reproduction of the soft body system requires too many calculations.

To summarize


Video game physics is a complex field in which developers seek a balance between realism and the limitations of computing power. Tricks, simplifications and physical engines allow you to quickly create a fairly realistic physics, to focus on more important aspects of the game.



The game should be interesting. Realism is not so important compared to the addictive gameplay. Game physics is still important - you need intuitive rules. At the same time, they can be changed to enrich the gameplay (remember the double jump).

If you want to better understand the physics of video games, then check out the relevant sections in the Unity Guide or the Lumberyard Guide .

All Articles