Skip to main content
55 votes
Accepted

How can I perform a deterministic physics simulation?

On handling floating point numbers in a deterministic way Floating point is deterministic. Well, it should be. It is complicated. There is plenty of literature on floating point numbers: What Every ...
Theraot's user avatar
  • 27.5k
43 votes

In games physics engines, what is "tunneling", also known as the "bullet through paper problem"?

What is tunneling and why it happens In video games, physic objects will have an specific position which is updated by the physics engine each frame based on its velocity and any forces applied to it. ...
Theraot's user avatar
  • 27.5k
34 votes
Accepted

Why integrate over accumulation?

...the inner workings of that function are generated via the appropriate mathematical formula... This will work for certain classes of problems, and the key phrase to search for is a closed-form ...
MooseBoys's user avatar
  • 1,311
17 votes

Moving player inside of moving spaceship?

The ship stays in place and everything moves. Mostly. In this answer I present three ideas of how to go about it, and I'm referencing the games I'm basing them on. I could not find out what approach ...
Theraot's user avatar
  • 27.5k
11 votes
Accepted

Difference between _process(delta) and _physics_process(delta)?

I made an more in depth explanation on GitHub: link. Graphics or Physics One difference is that _process is tied to graphics (it runs once per frame), while ...
Theraot's user avatar
  • 27.5k
10 votes
Accepted

Why not derive velocity from position updates in games?

In the vast majority of situations, calling getVelocity is a vastly preferable approach. You don't have to be polling objects on the off chance that next frame you are going to need a velocity (which ...
Cort Ammon's user avatar
  • 1,247
10 votes

How can I perform a deterministic physics simulation?

I work for a company which makes a certain well known real-time strategy game, and I can tell you that floating point determinism is possible. Using different compilers, or the same compiler with ...
Joe's user avatar
  • 201
9 votes

Why integrate over accumulation?

The problem with your approach is, that you don't have a history of your object. You can calculate the position if you move in a direction, but what happens if you hit something and bounce back? If ...
Linaith's user avatar
  • 536
8 votes

Why integrate over accumulation?

However, I don't understand why it's accumulated like this when it could just as easily be gotten by changing a function. For example: getPosition = makeNewFunction() which could return something that ...
Polygnome's user avatar
  • 803
8 votes

Why integrate over accumulation?

In the case of just a simple bouncing ball, coming up with closed form solutions is easy. However, the more complex systems tend to require solving an Ordinary Differential Equation (ODE). Numerical ...
Cort Ammon's user avatar
  • 1,247
7 votes
Accepted

physics engine without time steps

The problem is this only works if movement is linear and there is no possibility of other moving objects hitting one another. As soon as you have multiple forces changing the direction in non-linear ...
Stephane Hockenhull's user avatar
6 votes

How do force fields scale?

This is what I do in my N-Body simulation: particles far away can be aggregated in combined cells on a grid. (Multi-resolution Grid.) I use gravity calculations, but I am sure that charged attraction/...
Bram's user avatar
  • 3,734
5 votes
Accepted

How to handle player input with fixed rate variable fps time step?

I most often encounter this in the context of Unity, which has the following attributes: Input is checked once per displayed frame, before any of that frame's fixed/variable timestep updates Input ...
DMGregory's user avatar
  • 136k
5 votes

How can I perform a deterministic physics simulation?

I'm not sure if this is the type of answer you're looking for, but an alternative might be to run the calculations on a central server. Have the clients send the configuration to your server, let it ...
Glorfindel's user avatar
4 votes
Accepted

What is inertia in a physics engine?

I believe what we're looking at here more specifically refers to rotational inertia and inverse rotational inertia; not to linear inertia (nor inverse linear inertia). Wikipedia explains that ...
Louis Langholtz's user avatar
4 votes

Should a bowling game use a 2d or a 3d physics engine?

When developing games it is important to separate the game mechanics from the game representation on the screen. The game mechanics of bowling can be simplified to a pure 2d simulation by looking at ...
Philipp's user avatar
  • 121k
4 votes

Why not derive velocity from position updates in games?

Deriving velocity from position is actually used in some games & parts of games, when the implementation uses Verlet integration or similar techniques. Here we replace a conventional Euler ...
DMGregory's user avatar
  • 136k
4 votes
Accepted

How do fixed-point physics (engines) work?

TL;DR they work exactly the same; the difference comes from trade-offs like performance, value range and (sometimes) syntax. It's is possible to simulate floating- or fixed-point math, you just have ...
Shadows In Rain's user avatar
3 votes
Accepted

Applying friction force not working correctly

When velocity is 0, friction becomes a zero vector and you can't normalize it, that's why it becomes NaN
Bálint's user avatar
  • 15k
3 votes

Looking for collision detection algorithms for broad and narrow phases between non-convex polyhedrons

There are almost no algorithms to detect collision with a concave object, because there's no reason to have one. Every concave object can be approximated with convex object. See the following image ...
Bálint's user avatar
  • 15k
3 votes

Integrating Unity physics with Entitas

I literally just started looking at Entitas last night so there may be better solutions, but you could do something like the following: Create a component to store the collisions ...
Mattia's user avatar
  • 408
3 votes

Applying angular velocity to quaternion

In the following I use a vector hat to represent a quaternion and a unit vector hat to represent a unit quaternion. Let q(t) represent the quaternion rotation at any point in time. Let r be a ...
DarthRubik's user avatar
3 votes

Quake Physics ported to Unreal Engine?

This was a comment, but it's really an answer. You're not going to get Quake 3's peculiarities in Unreal. Strafe jumping, grenade jumps, rocket jumps, etc. Here's me doing a combination grenade/...
Almo's user avatar
  • 6,708
3 votes
Accepted

Unity Physics Simulation - Limitations / Inaccuracies? Bounciness of a ball (pool/snooker balls etc)

The realism of a physics simulation is the result of a lot of factors. A first easy step for games that need reliable physics would be to set the Collision Detection of a Rigidbody to Continuous ...
Karl Ramstedt's user avatar
3 votes

Detect collision point

In 2D rarely you have only one point of contact. I never played with collision resolution in 3D, but i guess this case will be even more rare. As for the answer, take a look at Erin Catto's (creator ...
crueltear's user avatar
  • 371
3 votes

How can I perform a deterministic physics simulation?

I'm going to give a counter-intuitive suggestion that, while not 100% reliable, should work fine most of the time and is very easy to implement. Reduce precision. Use a pre-determined constant time-...
leftaroundabout's user avatar
3 votes

AABB Collision Detection Confusion

There's actually a third option: storing AABBs as mins and maxs. That is, a Vector2 as the minimum x and minimum y, and another as the maximum x and maximum y values that the AABB occupies. This ...
Casey's user avatar
  • 2,075
3 votes

Moving player inside of moving spaceship?

The main issues here are, roughly: Floating-point imprecision and catastrophic cancellation. An ordinary (single-precision) float has 23 bits of mantissa. Say you're moving at 1.0 m/s, and you add ...
TLW's user avatar
  • 161
2 votes

Physics engine and squishing of stacked objects

I’m surprised that this question has such few views and votes. Stacking is a fundamental pathological use case of physics engines that implement a simple contact solver model. It showcases how the ...
Steven Lu's user avatar
  • 740
2 votes
Accepted

Physics engine and squishing of stacked objects

Sorry, I didn't know how to mark your comment as helpful. Turned out to be, I watched the GDC talk with great interest and along with my research, I could grasp why what I'm looking to do is just ...
Brunni's user avatar
  • 51

Only top scored, non community-wiki answers of a minimum length are eligible