Questions tagged [physics]

Relating to the motion of objects through space and time. Including concepts such as acceleration (thrust and gravity), mass, collision response, friction and more.

Physics in a game are the laws that are defined to govern the essence of motion within the game's world. This is about how things work at a core, mechanical level within the game engine, and is distinct from how the world setting's physics works at a conceptual, backstory level.

Questions with this tag deal with topics such as implementing gravity, controlling acceleration and velocity, or applying force in the game space to other objects.

Related tags include:

  • , which is specifically concerning physics within a 2D game space
  • , which is about handling genuine projectile motion calculations
  • , which is about handling the behavior and motion of rope-like entities
2461 questions
270
votes
11 answers

When should I use a fixed or variable time step?

Should a game loop be based on fixed or variable time steps? Is one always superior, or does the right choice vary by game? Variable time step Physics updates are passed a "time elapsed since last update" argument and are hence framerate-dependent.…
Nick Sonneveld
  • 2,849
  • 3
  • 19
  • 9
87
votes
3 answers

How do I create 2D water with dynamic waves?

New Super Mario Bros has really cool 2D water that I'd like to learn how to create. Here's a video showing it. An illustrative part: Things hitting the water create waves. There are also constant "background" waves. You can get a good look at the…
Berry
  • 1,279
  • 2
  • 11
  • 16
76
votes
5 answers

Good 2D Platformer Physics

I have a basic character controller set up for a 2D platformer with Box2D, and I'm starting to tweak it to try to make it feel good. Physics engines have a lot of knobs to tweak, and it's not clear to me, writing with a physics engine for the first…
user744
55
votes
6 answers

How can I implement gravity?

How can I implement gravity? Not for a particular language, just pseudocode...
L.P
  • 741
  • 1
  • 7
  • 9
52
votes
6 answers

How can I perform a deterministic physics simulation?

I'm creating a physics game involving rigid bodies in which players move pieces and parts to solve a puzzle/map. A hugely important aspect of the game is that when players start a simulation, it runs the same everywhere , regardless of their…
jvn91173
  • 624
  • 1
  • 6
  • 10
52
votes
7 answers

2D Platformer AABB collision problems

I have a problem with AABB collision resolution. I resolve AABB intersection by resolving the X axis first, then the Y axis. This is done to prevent this bug: https://i.sstatic.net/NLg4j.png The current method works fine when an object moves into…
Vittorio Romeo
  • 1,200
  • 3
  • 16
  • 33
47
votes
3 answers

How to determine which thrusters to turn on to rotate the ship?

The configuration of the ship changes dynamically, so I have to determine which thruster to turn on when I want to rotate the ship clockwise or counter clockwise. The thrusters are always axis aligned with the ship (never at an angle) and are either…
migimunz
  • 741
  • 5
  • 9
47
votes
2 answers

How to make a character jump?

I am currently making a game in C# using Direct X 9.0. The game remake is Donkey Kong NES. I have nearly everything completed, but I am having problems with the physics of Mario's jump. I have variables declared for the Y and X co-ordinations. I was…
Sarah
  • 473
  • 1
  • 5
  • 4
44
votes
2 answers

Water/Ocean simulation and physics

I'm looking for some references about water simulation, and how to model it's interaction with bodies (like boats, ships, submarines). I've found a lot of references on the visual aspects of water (waves, reflection, etc), but very little about how…
Alexandre
  • 565
  • 1
  • 4
  • 6
43
votes
6 answers

Analysis of Mario game Physics

I know there's a breakdown of Sonic the Hedgehog physics found here , and I was wondering, does there exist a breakdown of any of the Mario games? Something similar to this but for Mario is what I'm interested in!
Jeff
  • 2,478
  • 4
  • 24
  • 29
42
votes
1 answer

How to differentiate landing on top of an object from falling down the side?

I am looking for a conceptual solution to my problem. It's a simple platformer-alike game where player can move horizontally during free-fall. Consider those two cases: In the first case, from game experience point of view, the player should land on…
weno
  • 541
  • 4
  • 10
41
votes
5 answers

How can I give the illusion of height to a ball in 2D?

In 2D top down soccer games, sometimes a ball is given the illusion of being in the air, like below: How can I achieve this?
Donald
  • 524
  • 1
  • 4
  • 8
39
votes
11 answers

In Pong, how do you calculate the ball's direction when it bounces off the paddle?

I'm trying to wrap my head around this very Hello World-y problem in game development. I've created a TicTacToe game in XNA so I guess the next step would be a Breakout clone. Keep in mind that I have no knowledge on game programming or even what…
Sergio
38
votes
2 answers

Why do we use the Pythagorean theorem in game physics?

I've recently learned that we use Pythagorean theorem a lot in our physics calculations and I'm afraid I don't really get the point. Here's an example from a book to make sure an object doesn't travel faster than a MAXIMUM_VELOCITY constant in the…
Starkers
  • 961
  • 2
  • 12
  • 21
38
votes
2 answers

How do I make a character capable of walking on walls?

I am trying to get a character to move like a spider: Given a rising slope which a ball would normally not be able to roll up, the spider would slowly crawl up. Similarly, given a mid-air rectangular platform, instead of falling down when reaching…
pyko
  • 493
  • 1
  • 5
  • 8
1
2 3
…
99 100