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.

2,153 questions
Filter by
Sorted by
Tagged with
100k 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 ...
37k 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 "...
43k 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 ...
10k 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 The ...
74k views

How can I implement gravity?

How can I implement gravity? Not for a particular language, just pseudocode...
3k 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 ...
12k views

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 ...
74k 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 ...
13k 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 (...
9k views

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?
5k views

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 ...
23k 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 ...
10k 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 ...
23k 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 ...
5k views

Calculating the rotational force of a 2D sprite

I am wondering if someone has an elegant way of calculating the following scenario. I have an object of (n) number of squares, random shapes, but we will pretend they are all rectangles. We are ...
11k 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 ...
9k views

Implementing a wrapping wire (like the Worms Ninja Rope) in a 2D physics engine

I've been trying out some rope-physics recently, and I've found that the "standard" solution - making a rope from a series of objects strung together with springs or joints - is unsatisfying. ...
3k views

Movement prediction for non-shooters

I'm working on an isometric 2D game with moderate-scale multiplayer, approximately 20-30 players connected at once to a persistent server. I've had some difficulty getting a good movement prediction ...
9k views

Do 2D games have a future? [closed]

I'm currently working on a 2D soft-body physics engine (since none exist right now -_-), but I'm worried that there's no point to spending what will most likely be years on it. Although I love ...
74k 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 ...
13k 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 ...
3k views

How did EA DICE create destructible environments in Battlefield Bad Company 2 and Battlefield 3? [closed]

How did the folks at EA DICE create destructible environments in Battlefield Bad Company 2 and Battlefield 3? Did they just assemble the buildings out of predefined sub-regions, that break apart when ...
10k views

Pros and cons of different integrators [closed]

When creating things like physics in games you need an integrator. I've seen Verlet integration mentioned several places as a great alternative to Euler integration. For instance in the famous ...
7k views

Simulating pressure in a grid based liquid simulation

I have a 2D grid based water system in my XNA game, we have a method using cellular automata to simulate water falling and spreading. Example of water flowing down a slope: Each tile can contain a ...
19k views

Quad tree vs Grid based collision detection

I'm making a 4 player co-op r-type game, and I'm about to implement the collision detection code. I've read a lot of articles and stuff about how to handle collision detection, but I'm having a hard ...
12k views

What is the difference between an impulse and a force related to a physics engine?

What is the difference between an application of an impulse and an application of a force in relation to a physics engine?
6k views

How to make sure spinning objects hit a target with the right end?

I'm working on a throwing knife type weapon where a player free aims and then throws a knife. The knife spins through the air and on collision stops spinning and parents itself to the object it ...
2k views

I'm building a space exploration game and I've currently started working on gravity ( In C# with XNA). The gravity still needs tweaking, but before I can do that, I need to address some performance ...
2k views

What is the point of “delta” in this code? Does it reflect a standard thing in game dev?

I know very little about game programming but would like to learn more. I am trying to understand the code for this game. I am trying to understand why the code is passing a "delta" to Shipcontrols.js,...
4k views

Optimizing gravity calculations

I've got a bunch of objects of varying size and velocity which gravitate towards each other. On every update, I have to go over every object and add up the forces due to gravity of every other object. ...
2k views

Correctly Implementing a “Double Jump”

I'm working on a 2D iPhone game using Corona (Trial version, so I can't use their forums). The game involves the character falling through the sky, and I'm trying to implement a "double jump" for the ...
4k views

Momentum and order of update problems in my physics engine

This question is a "follow-up" question from my previous one, regarding collision detection and resolution, which you can find here. If you don't want to read the previous question, here's ...
21k views

What is a good book on physics for game development? [closed]

I'm looking for a good beginners' book on the subject of physics in game development. Something that focuses on 2D games would be preferable.
3k views

How can I Intercept object with a circular motion

I am creating a 2d space game and need to make the spaceship intercept a planet. I have working code for straight line intercepts but cannot figure out how to calculate the planets location in a ...
10k 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 ...
6k views

How can I create a stretchy, breakable pizza cheese material?

I want to create realistic pizza and allow user interact with it. What I want: What I created: I created model of the pizza (8 pieces) in Blender, then imported it into Unity. The piece of pizza ...
6k 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 ...
2k views

Data structures for interpolation and threading?

I've been dealing with some frame-rate jittering issues with my game lately, and it seems that the best solution would be the one suggested by Glenn Fiedler (Gaffer on Games) in the classic Fix Your ...
21k 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 ...
8k views

Why is RK4 better than Euler integration? [closed]

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 ...
10k views

Is there a 2d physics engine that can model fluids and gases? [closed]

At this point the platform and programming language don't matter I would just like to know if something out there exists for this. Any help is appreciated.
6k 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 ...
2k views

AI control for a ship with physics model

I am looking for ideas how to implement following in 2D space. Unfortunately I don't know much about AI/path finding/autonomous control yet. Let's say this ship can move freely but it has mass and ...
6k views

Ideas for 2D Water Simulation

I am looking for any input on simulating water in 2D, against a rather large (call it) blocked/not blocked array (viewed from the side). I have come up with the following ideas: Cell Automata Do a ...
9k views

Are collision detection always O(n^2)?

Are physics engine able to decrease that complexity, for example by grouping objects who are near each other and check for collisions inside this group instead of against all objects ? (for example, ...
10k 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 ...
7k views

In a 2D platform game, how to ensure the player moves smoothly over sloping ground?

I'm developing a physics engine for a 2D platform game. I'm using the separating axis theorem for collision detection. The ground surface is constructed from oriented bounding boxes, with the player ...
50k views

Typical Maximum steering angle of a real car

I'm building a car sim in Unity3D. I'm trying to set the properties of the car to be as realistic as possible. I can't seem to get a straight answer on Google so I thought of asking here. What is the ...