seems like every game with a car has this happen occasionally, and I was wondering what the underlying theme is in how vehicles are coded in these games that makes it such a common glitch?
no loss of energy upon impact, and fully rigid objects cause speed energy to fully be transfered to speed energies in other directions without deformation or intermolecular friction slowing things down
I remember a developer posting an update to “Last Oasis” explaining why this phenomenon occurred in their games. It’s not exactly racing, but it is moving vehicles. The way they explained it was essentially that it was due to “Static” objects colliding with “Dynamic” objects. I don’t understand it fully, but from what I could gather, the physics engine doesn’t know how to properly handle when a dynamic object collides with an object (at high speeds) that is static, meaning the object they collide with should not move under any circumstance. Because the dynamic object (the vehicle in this case) is moving so fast, it goes inside of the static object and the physics engine’s job is to now remove this anomaly, generally causing it to wildly flip out and get pushed out of the other object in any way possible. But since they’re lodged together, there’s no concrete way of doing it (physics engines don’t support this phenomenon) hence the random rapid spinning or being launched.
Think of the game Halo when you drive a warthog into a pole and the hood of the vehicle gets lodged inside of it and the car starts spazzing out. The physics engine is trying to remove the collision, but the properties of both objects force them to remain in the same position. The warthog is constantly trying to be removed, but according to the physics, it can’t be removed.
Take my explanation with a grain of salt. I’m no game dev or anything, but I’ve done a couple very small projects where the same phenomenon occurs in Unity Game Engine.
The physics in a game is simulated.
Someone wrote an approximation of how physics should behave with the constraints of a game (performance).
This means it’s not perfectly accurate to real life, just good enough.
In some cases, especially with very large or very small numbers, it can cause weird behavior because the game’s physics system isn’t perfectly accurate to real life.
Game physics engines have to be imprecise for several reasons, but importantly they have to work in with snapshots. In reality, as far as we know, things move with infinite precision. When things collide they go from being apart to hitting smoothly. But in a game, if there are two objects moving towards each other then one moment they’re apart and the next they would be **overlapping**.
When things overlap the game has to figure out how to deal with it. One way is to force them apart and with speed based on how far they overlapped. Imagine you have two really strong magnets pointed the wants-to-push-apart direction. You probably can’t make them touch just by forcing them together. But what if they magically teleported right next to each other? They’d go flying away at high speed, right?
So one way they get big forces applied is by the engine trying to untangle objects that somehow ended up way overlapping (and how this can happen is also a bit complicated).
Why does that make them spinny? Well things get spinny when you hit them on the edge and not the center (sorta, this is a simplification). But if you’ve ever spun a bicycle wheel you know how you hit it a bunch of times on the edge to make it spin fast, right? Well, now you combine the thing I said before about objects getting pushed away real fast, except instead of away you get a push on an edge like that and it goes super spinny.
Now everything I’ve said is a simplification. And physics engines all have different details about how exactly they do these things. But the approximation of collisions combined with working with framerates is a big part of why things go wrong in this particular way.
It could be a number of reason but most of them relate to how numbers are stored and manipulated by computers.
Computer store everything as 0 & 1, electricity or no electricity. So to store and manipulate number, you need to convert them into bundle of 0 and 1. So 0 is 0, 1 is 1, but 2 is 10, 3 is 11, 4 is 100 etc.
Now you cannot go indefinitely like that, as computer have limited amount of memory, so usually you take a certain amount of 0&1 and make a group that will express a number. For example 8 of them. That mean you can store from 00000000 (so 0) to 11111111 (255). But that also mean if you add 00000001 and 11111111 together, the result 100000000 (1 followed by 8 zero) doesn’t fit, you only have 8 space, so it will loose the 9th number (the 1) and become 00000000 (8 zero, so 0 again) which is the wrong result.
Now this is for very simple number and there is more complex version of that for number with decimal part etc. But when the game compute the forces that move the car, sometime, because there is an extreme shock at high speed etc.. The computation will create that exact problem and the result will be wrong. But the problem is that this result is the new speed of the car that will be used the next time. So now you’re using a wrong value, which in turn will give a new wrong value. Etc. Etc. Now you are in a downward spiral of bad value that just never end.