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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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/...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
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 ...
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
...
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 ...
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♦
- 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 ...
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 ...
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-...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
physics-engine × 248physics × 130
collision-detection × 38
collision-resolution × 29
unity × 28
box2d × 24
c++ × 18
2d × 17
bullet-physics × 15
rigid-body-dynamics × 13
mathematics × 12
3d × 11
c# × 10
java × 10
optimization × 9
simulations × 8
javascript × 7
rigidbody × 7
rotation × 6
opengl × 5
libgdx × 5
algorithm × 5
game-mechanics × 5
architecture × 4
directx × 4