Eli5 how can video games perfectly replicate real life physics

385 views

Like making a ball bounce…etc

In: 0

12 Answers

Anonymous 0 Comments

Easy:

By *not* perfectly replicating real life physics.

Physics is basically just lots and lots of mathematical equations. You plug in information for the inputs, and the equations give you the output.

For a ball bouncing, you’d plug in its starting position, its starting velocity, its mass, and acceleration due to gravity, and we have equations that will tell you how it moves.

Computers are very good at doing math, so all they’re doing is the same thing: taking inputs, performing math, and producing outputs, then telling the computer how to draw that output.

But computers don’t *perfectly* follow along with physics equations. They are simply too complex. They’ll use simplified equations that produce good enough results that look real. The fewer variables you have to consider, and the simpler the math, the faster the computer can produce results.

Anonymous 0 Comments

Well usually they don’t, and sometimes that’s intentional. But physics is just math and it comes down to looking at the formulas from the perspective of the game engine. Gravity is just downward force, and a collision detection to stop you going through the floor. Air resistance/friction; that’s negative force. And in fact, you can exploit that in some games.

A common misconception, however, is when something is labeled as a physics sim when it isn’t. Take water for example; real water simulations are massive particle simulations, even modern game engines can’t handle. How oceans are usually simulated, is with displacement, where they deform the mesh using rules that make it act like an ocean.

What it really comes down to, again, is taking the concept of what you want to do, and translating that to how you would program it. Another example is lighting. In real life, waves emit from the sun and bounce into our eyes, but that means a lot of those rays are unnecessary because you’ll never see them. So games do it in reverse, shooting the ray from the camera and checking if it hits a light source.

Anonymous 0 Comments

They don’t.

The motion of a ball in real life is way more complicated than in any video game because of all the interactions with different surfaces and the atmosphere and so on.

Most video games don’t bother with any of that because you won’t notice the difference if they keep it simple.

Then it’s mostly code. You tell the ball how fast it should fall to the ground and then tell it to bounce back up again when it hits the ground. It’s fairly simple to have the bounce speed relative to whatever speed it hit the ground with.

Tweak it until it fills right and you’re good.

Not only is it too difficult to fully replicate real world physics, it’s almost mostly not desirable. Gamers aren’t playing games expecting perfect recreations of the real world. Unless it’s a simulator, you don’t need to be fully accurate, you just need it to be good enough for whatever game you’re trying to make, and often that means deliberately ignoring things that don’t fit (for example, most shooters deliberately ignore bullet physics because it’s more satisfying if the bullet just hits whatever you were aiming at)

Anonymous 0 Comments

Well usually they don’t, and sometimes that’s intentional. But physics is just math and it comes down to looking at the formulas from the perspective of the game engine. Gravity is just downward force, and a collision detection to stop you going through the floor. Air resistance/friction; that’s negative force. And in fact, you can exploit that in some games.

A common misconception, however, is when something is labeled as a physics sim when it isn’t. Take water for example; real water simulations are massive particle simulations, even modern game engines can’t handle. How oceans are usually simulated, is with displacement, where they deform the mesh using rules that make it act like an ocean.

What it really comes down to, again, is taking the concept of what you want to do, and translating that to how you would program it. Another example is lighting. In real life, waves emit from the sun and bounce into our eyes, but that means a lot of those rays are unnecessary because you’ll never see them. So games do it in reverse, shooting the ray from the camera and checking if it hits a light source.

Anonymous 0 Comments

Easy:

By *not* perfectly replicating real life physics.

Physics is basically just lots and lots of mathematical equations. You plug in information for the inputs, and the equations give you the output.

For a ball bouncing, you’d plug in its starting position, its starting velocity, its mass, and acceleration due to gravity, and we have equations that will tell you how it moves.

Computers are very good at doing math, so all they’re doing is the same thing: taking inputs, performing math, and producing outputs, then telling the computer how to draw that output.

But computers don’t *perfectly* follow along with physics equations. They are simply too complex. They’ll use simplified equations that produce good enough results that look real. The fewer variables you have to consider, and the simpler the math, the faster the computer can produce results.

Anonymous 0 Comments

Well usually they don’t, and sometimes that’s intentional. But physics is just math and it comes down to looking at the formulas from the perspective of the game engine. Gravity is just downward force, and a collision detection to stop you going through the floor. Air resistance/friction; that’s negative force. And in fact, you can exploit that in some games.

A common misconception, however, is when something is labeled as a physics sim when it isn’t. Take water for example; real water simulations are massive particle simulations, even modern game engines can’t handle. How oceans are usually simulated, is with displacement, where they deform the mesh using rules that make it act like an ocean.

What it really comes down to, again, is taking the concept of what you want to do, and translating that to how you would program it. Another example is lighting. In real life, waves emit from the sun and bounce into our eyes, but that means a lot of those rays are unnecessary because you’ll never see them. So games do it in reverse, shooting the ray from the camera and checking if it hits a light source.

Anonymous 0 Comments

They don’t.

The motion of a ball in real life is way more complicated than in any video game because of all the interactions with different surfaces and the atmosphere and so on.

Most video games don’t bother with any of that because you won’t notice the difference if they keep it simple.

Then it’s mostly code. You tell the ball how fast it should fall to the ground and then tell it to bounce back up again when it hits the ground. It’s fairly simple to have the bounce speed relative to whatever speed it hit the ground with.

Tweak it until it fills right and you’re good.

Not only is it too difficult to fully replicate real world physics, it’s almost mostly not desirable. Gamers aren’t playing games expecting perfect recreations of the real world. Unless it’s a simulator, you don’t need to be fully accurate, you just need it to be good enough for whatever game you’re trying to make, and often that means deliberately ignoring things that don’t fit (for example, most shooters deliberately ignore bullet physics because it’s more satisfying if the bullet just hits whatever you were aiming at)

Anonymous 0 Comments

Easy:

By *not* perfectly replicating real life physics.

Physics is basically just lots and lots of mathematical equations. You plug in information for the inputs, and the equations give you the output.

For a ball bouncing, you’d plug in its starting position, its starting velocity, its mass, and acceleration due to gravity, and we have equations that will tell you how it moves.

Computers are very good at doing math, so all they’re doing is the same thing: taking inputs, performing math, and producing outputs, then telling the computer how to draw that output.

But computers don’t *perfectly* follow along with physics equations. They are simply too complex. They’ll use simplified equations that produce good enough results that look real. The fewer variables you have to consider, and the simpler the math, the faster the computer can produce results.

Anonymous 0 Comments

They don’t.

The motion of a ball in real life is way more complicated than in any video game because of all the interactions with different surfaces and the atmosphere and so on.

Most video games don’t bother with any of that because you won’t notice the difference if they keep it simple.

Then it’s mostly code. You tell the ball how fast it should fall to the ground and then tell it to bounce back up again when it hits the ground. It’s fairly simple to have the bounce speed relative to whatever speed it hit the ground with.

Tweak it until it fills right and you’re good.

Not only is it too difficult to fully replicate real world physics, it’s almost mostly not desirable. Gamers aren’t playing games expecting perfect recreations of the real world. Unless it’s a simulator, you don’t need to be fully accurate, you just need it to be good enough for whatever game you’re trying to make, and often that means deliberately ignoring things that don’t fit (for example, most shooters deliberately ignore bullet physics because it’s more satisfying if the bullet just hits whatever you were aiming at)

Anonymous 0 Comments

Physics is all about coming up with functions and rules that predict how things will move. Video games can just treat this as a recipe. You might get a problem in a high school physics class that says “A ball is 5 meters in the air at time 0, gravity is 9.8 meters per second squared, where will the be at time 1?”

A video game just solves that same problem repeatedly. “The ball has this velocity, it’s being pulled in whatever direction, where will it be in 16ms? Okay, great, move the ball there, draw the screen again.” Then it repeats the process, perhaps 60 times every second.

Many times per second, the computer simply uses regular physics equations to update everything’s velocity and position to a new position. This is really convenient because it makes certain things a lot simpler, like the famous “three body problem.” It’s really hard to know where three things orbiting each other are going to be after N amount of time, but it’s really easy to estimate fairly accurately where they’ll all be a tiny amount in the future, and for the most part, it works (although over time the calculated solution will diverge from what would happen in real life, but it’ll still look okay).

The biggest problem is collisions. Things bounce into each other, and especially at high speeds, it really matters EXACTLY when they bounced and at what angle. This is tricky to get right. A bullet can be on one side of a tank at time N and on the other side of the tank at time N+16ms.

The second biggest problem is that most real things aren’t completely inelastic. This makes calculations more expensive. Programmers get creative here, and there are a variety of approaches.