# Tagged Questions

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

10answers
68k views

### 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 ...
2answers
33k views

### 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 ...
7answers
32k views

### 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 ...
5answers
36k views

### Good 2D Platformer Physics [closed]

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 ...
6answers
37k views

### How can I implement gravity?

How can I implement gravity? Not for a particular language, just pseudocode...
5answers
4k views

### How to lead a moving target from a moving shooter

I saw this question: Predicting enemy position in order to have an object lead its target. My situation is a little different though. My target moves, and the shooter moves. Also, the shooter's ...
3answers
1k views

### Impulsioned jumping

There's one thing that has been puzzling me, and that is how to implement a 'faux-impulsed' jump in a platformer. If you don't know what I'm talking about, then think of the jumps of Mario, Kirby, and ...
5answers
9k views

### Lag compensation with networked 2D games

I want to make a 2D game that is basically a physics driven sandbox / activity game. There is something I really do not understand though. From research, it seems like updates from the server should ...
7answers
7k views

### 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: http://i.stack.imgur.com/NLg4j.png ...
3answers
11k views

### Is there an algorithm for a pool game?

I am looking for algorithm to calculate direction and speed of balls in a pool game. I am sure there has to be some type of open source code for this since pool games are some of the oldest computer ...
5answers
7k views

### How do I detect the direction of 2D rectangular object collisions?

After this question, I need some more help. How can I find out which side of a rectangle a collision came from and react accordingly? The blue arrows are the paths that some circular objects ...
4answers
3k views

### How do I calculate rotation caused by bounce friction?

Following on from my previous question: I have the ball quite realistically bouncing from surfaces it hits. Now I'd like to make it spin from the friction of the hit. Showing this is simple enough: I ...
1answer
387 views

### How to implement deceleration and stopping over a certain distance [duplicate]

So I have a a character, say a spaceship. It needs to move distance R, and in direction T (Theta). So say if The object is at (0,0), and it needs to get to (4,3), it has R = 5 and T = about 36 degrees....
6answers
12k views

### How do I build a 2D physics engine? [closed]

The most advanced games I've made are a 8-ball pool game made with the physics engine Box2dFlashAS3 and a platform game with levels. When I did platform games, I've always wished to know how to make ...
2answers
8k views

### 2D Planet Gravity

I'm trying to make a simple game where a spaceship is launched and then its path is effected by the gravity of planets. Similar to this game: http://sciencenetlinks.com/interactives/gravity.html I ...
2answers
4k views

### How are physics or graphics components typically built in a component-oriented system?

I have spent the last 48 hours reading up on Object Component systems, and feel I am ready enough to start implementing it. I got the base Object and Component classes created, but now that I need to ...
1answer
3k views

### How do I detect ledges?

In my game, I'd like my character to be able to grab and hold onto ledges, and to be able to pull themselves up if there's room to do so. How do I detect if there's a ledge, and if the character has ...
2answers
6k views

### Why is RK4 better than Euler integration?

At the end of these great slides, the author compares all the different integrators presented. One way or another, they all fall short except for Improved Euler Integration and Runge Kutta 4 ...
3answers
5k views

### Why is my velocity decaying?

Programming in Java. Tinkering around with physics. My entities all have position and velocity. In the main loop, all I'm doing is applying gravity and bouncing off the edges, like so: // add ...
2answers
907 views

### Tracking Object Position - Firing on a Trajectory

How can I calculate the position of an object after "firing" it from a fixed point? I am to create a small game - most likely with canvas (pure HTML, JS based) or Adobe Flash - in which the player ...
3answers
5k views

### Finding the contact point with SAT

The Separating Axis Theorem (SAT) makes it simple to determine the Minimum Translation Vector, i.e., the shortest vector that can separate two colliding objects. However, what I need is the vector ...
2answers
914 views

### Show path of a body of where it should go after linear impulse is applied

I am making a game with Andengine and Box2D. I have a dynamic body and I apply linear impulse on the body to move it around when the user have touched the screen. Now I want to show the path where ...
2answers
1k views

### Why isn't this physics code scaling velocities separately?

I'm working my way through this book and I'm trying to work this code out: var squaredVelocity = this.velocity.x*this.velocity.x + this.velocity.z*this.velocity.z; if (...
3answers
17k views

### 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 "...
3answers
2k views

### 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 ...
4answers
6k views

### Vehicle physics with skid

How would I go about creating vehicle physics for a car that can loose traction? I want it to seem like the driver has a flat foot, so when you press the gas, they cars driving (rear) wheels loose ...
3answers
4k views

### How do I handle moving platforms in a platform game?

I don't want to use box2d or anything, I just want simple moving platforms (up-down, left-right, diagonal and circular paths). My question is to handle the update order / control hierarchy so that the ...
2answers
2k views

### Implementing a homing missile [duplicate]

I'm having some trouble implementing a homing missile that satisfies what I'm looking for. I have already tried the Seeking and Arrival behaviours described in this link, but none of them were what I ...
4answers
5k views

### How to deal with corner collisions in 2D?

I'm writing a top down 2d XNA game. Since its my first I'm trying to write the physics and collision stuff myself to learn it. Whenever my player sprite character attempts to move into a position ...
4answers
4k views

### Which Side Was Hit?

I am working on an Android game and I have two objects A and B (both rectangles) and when they collide I simply want to know which side of B was hit. I have detected the collision fine, but I am ...
4answers
1k views

### Animated examples of different interpolations formulas: any link? [closed]

I remember having spotted a link to a huge page with different equations to non linear interpolation curves, for example if you want to stop a car smoothly, etc. Those can sometime be useful to ...
1answer
4k views

### Angle of Reflection

I have this "Breakeout style" game. I have a cannon at the center, blocks around the cannon and pads around the blocks. This is how the game looks like: I've managed to get the collision per ...
1answer
1k views

### Algorithm for randomly generating reachable platforms

I want to randomly generate reachable platforms on the fly for a 2D game. Right now, I am just creating platforms at random x,y positions. Only 4 platforms can exist at once, so once the 5th one is ...
3answers
3k views

### Where to start for implementing vehicle physics? [closed]

A little background for myself. I am relatively experienced with 3rd part physics engines such as Havok, Box2D, Bullet and have successfully integrated them in custom engine(s). I have also made a ...
3answers
11k views

### Determine Resulting Angle of Wall Collision

So I have an object moving in a direction towards a fixed horizontal or vertical wall. How do I compute the angle that the object should bounce off at? The object can approach the wall at an arbitrary ...
3answers
2k views

### Resources to learn programming rigid body simulation

Where I can start learning about simulating rigid bodys 2d and 3d ?
1answer
804 views

### How do I determine a good path for 2D artillery projectiles?

I'm building a little "tank wars" game (like this one). I understand the math, and I am able to define a parabola from the launcher to the objective I want to reach. The parabola depends on the ...
1answer
372 views

### Spaceship acceleration for following waypoints

I'm creating a turn based space ship strategy game with simultaneous turn resolution similar to Steam Birds. After all the orders are given, the ships run through a real time simulation where they ...
4answers
5k views

### Physics engine recommendation which can simulate pool game correctly? [closed]

I'm making a pool-game like game. This game requires correct (or very accurate) reflective bounces. I tried Box2D and Bullet Physics, but they both have this problem. If there is a wall on top of ...
5answers
1k views

### How can I simulate shattering glass?

I need to make a simulation with stone thrown through a glass window. How can I accomplish that? I mean, I was thinking about making a 3D model of a stone and glass in 3D Studio Max 2012, shatter the ...
2answers
2k views

### How can I implement rectangle collision response?

I am working on a game in JavaScript and my current implementation of collision uses the shortest distance to push the intersecting object away, which isn't always correct. I've made this diagram of ...
1answer
3k views

### Friction in 2D game

I'm developing a 2D platformer, although this question could probably apply to just about any 2D type physics; What is the equation for friction? I have sort of a hacky type of friction set up in my ...
1answer
387 views

### Using Box2D for range detection?

I have two entities. One has a sword, one has a bow and arrow. When the bow entity is 100 units away, he needs to begin attacking. Likewise, when the sword entity is 10 units away, he needs to begin ...
2answers
8k views

### 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 ...
2answers
7k views

### 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 (...
6answers
12k views

### About floating point precision and why do we still use it

Floating point has always been troublesome for precision on large worlds. This article explains behind-the-scenes and offers the obvious alternative - fixed point numbers. Some facts are really ...
6answers
10k views

### Analysis of Mario game Physics [closed]

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 ...
2answers
5k views

### 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 ...
3answers
2k views

### How does one avoid the “staircase effect” in pixel art motion?

I am rendering sprites at exact pixel coordinates to avoid the blurring effect caused by antialiasing (the sprites are pixel-art and would look awful if filtered). However, since the movement of the ...
5answers
2k views

### How could you parallelise a 2D boids simulation

How could you program a 2D boids simulation in such a way that it could use processing power from different sources (clusters, gpu). In the above example, the non-coloured particles move around ...