How physics in games work

475 views

In a game like GTA, for example. You have a huge variety of vehicles, including flying cars and bikes. How does it work? Is it arbritary (“this will fly, period”) or they design It to fly in that universe, according to those rules, Just like they would do in real life?

In: Physics

4 Answers

Anonymous 0 Comments

Obviously it varies depending on the game.

Some games try to simulate accurate physics, such as Kerbal Space Program.

Other games are on the opposite side of the spectrum, for example platformers such as Super Mario. “Flying” objects simply have a value saying that gravity doesn’t apply to them.

And some games are in between. Games like GTA do have some physics in them to make them appear realistic, but it’s not like they do the actual math with lift, air resistance and the likes. Instead they just set a few basic values to use for the physics calculation, for example a car might have gravity X while an airplane has gravity X/5.

Anonymous 0 Comments

Depends on the size and scope of the game and the available hardware. I mean you can to some degree make physics simulations and sell them as games and for programmers it might even be easier to apply the same formula to all objects to compute how they should behave rather than to move every piece individually.

However the more objects you have on screen and the more details you treat as objects the more computationally expensive that’s going to be and so instead of computing accurately how every leaf is moving you just render animations for your 4 weather conditions and call it a day.

Edit: And in terms of how you do these simulations, well you essentially compute them step by step. So while in real physics you’d compute a mathematical formula that gives you a value for every small number and the interval between them. Well the computer just computes the values and then computes the values for what happens x milliseconds down the line and assumes that nothing has significantly changed in between. Now the smaller the intervals the closer to reality (unless you’re dealing with chaotic systems).

Anonymous 0 Comments

Often, they will literally just make objects flies. It’s rare to even see calculations of even force interaction. Most objects in a typical 3D care about 3 informations: positions and velocity, and collision detection. Position and velocity are simple enough. Collision detection is already very hard to do accurately, so the game often cheat even this. To make an object flies, for example, simply change its velocity values.

Acceleration/momentum get involved once the game need to model high speed movement where it would looks weird to have abrupt velocity changes.

Actual simulation of collision force do happen in game physics, but they’re rarely used because they’re very wonky. Unless you’re playing a game where the point is physics simulation, chances you won’t see any of this at all, or maybe only when it doesn’t matter (ragdoll).

Light are either simulated in a very approximated manner. Raytracing is rare, as of now, even then they’re still very crude approximation of light.

Anonymous 0 Comments

Depends on which game, the others have already explained it.

Funny thing, if you can somehow make a game, that simulates every particle, every atom and make a world with it, the graphics should look exactly like real life (Of course, it won’t because of the screen, the PC etc but if you could ignore the real world difficulities, then it would).