> Interestingly, while the engine has the most moving parts in real life, in code, it's the simplest piece of the entire car simulation. Because at its core, the engine is just a torque calculator. It's concerned with producing a single output: rotational torque, from a set of inputs. It is essentially a blackbox.
This just reminded me of AngeTheGreat's incredible video series showing his engine simulator- absolutely worth checking out, considering it's optimized enough to run in real-time! The fact that he's simulating it well enough to generate realistic sound is absolutely mind-blowing.
In addition to some other things, I was responsible for all vehicle simulation in Army of Two. This article is a good starting point. I was glad they mentioned implementing Pacejka’s tire model and the transmission differential in the article - those help a lot. Aside from that, I was surprised (not surprised) how important an anti-roll bar physics sim and suspension sim helped make driving feel “fun”.
That’s the most important follow up. Without it, you’ll notice that the driving feels icy - I see it in the demo video. Most folks who fail to do the anti-roll bar and suspension wind up with cars that easily flip on turns - so they make the tires slip or they play with the surface friction, which makes the driving experience worse.
This very closely mirrors what I discovered when I made Flightle[1].
I made it in anger when I played a sidescrolling flight "simulator" on my phone in which the plane didn't behave anything like a plane! I figured "how hard can it be" and started learning a lot about how planes fly. It turned out there was a level of abstraction that was just right. Too unrealistic felt static and unsatisfying. Too realistic was difficult to calibrate for fun gameplay.
A while ago I made a game for iOS that simulates vehicles and drifting. It was built in SpriteKit but very easy to do in any 2d game engine. The idea is: you put two wheels in front, connect them to the rectangle car shape with pin joints and then you apply force to the wheels. The angle of the force is very easy to calculate:
x = force * cos(bodyRotation + wheelRotation)
y = force * sin(bodyRotation + wheelRotation)
Wow. Sincerely enjoyed this. Will re-read for the tire model alone.
On the other end of the spectrum, playing purely for fun with no regard for simulation or realistic anything ... I'll take a 1980s spinner wheel Super Sprint arcade cabinet any day for guaranteed smiles per mile.
It's a cool post but I am very confused by the intro.
It makes the case that cars in games offer a wide variety of unrealistic experiences and says this is unlike guns.
Is that really true? I've played games with homing bullets, slow projectiles, enormous projectiles, gravity guns, rocket jumping, hit scan guns, guns with bullet drop, freeze guns, ... idunno, I think there's a lot of variety in guns that are about the experience and not about simulating physics.
> It's because when it comes to cars, we derive our expectations of them not just from first hand experience. Our understanding of what “driving fast” feels like is often built from second-hand sources; films, games, pop culture.
And then this just feels like a theorycrafted thing with zero evidence. It's also even more true of guns than of cars, isn't it?
But then, there's stuff like, uh, jumping, where there is just as wide a variety in how you can jump in games even though my expectations about jumping come a lot more from actually jumping than do my expectations about driving come from actually driving.
Unreal Engine comes with two car demo projects. The first one is the "Hello World" of Unreal, and has a simple vehicle. The second one has an actual suspension model.
Amazing article. I've always been curious how hard it would be to simulate accurate tires in particular, and I'm also interested in how the sound of engines is generated.
A quick typo though: s/Imperically/empirically (I guess)
there is a whole family of filetype glTF extension standards for vehicles so a completed asset will be rendered effectively across different game/world/ engines and coordinate the physics etc ... [1] is an example :
I realize the author goes super hard into actual physical vehicle hardware components, but every time I think about super good feeling vehicles in video games, I think about how ridiculous the Warthog in Halo 1 feels, but the vehicle physics in that game seems to make almost no sense, and when vehicles go flying it's hilarious and absurd, and I wish some developer from the Halo 1 days of Bungie would talk about it.
I recall the Warthog and other vehicles actually defining some specific properties about vehicles like RPM and gear ratio, at least I think, because in first person you'd see some of those properties reflected in the dashboard of say the Warthog, or you'd hear it in the audio for a covenant vehicle.
But wow, man, what great feeling vehicles. Nothing else like it in the industry, in my opinion. The ridiculous feeling of vehicles in Grand Theft Auto 4 came really close, but those seemed to be much, much more detailed from vehicular motion and damage-taking perspectives.
Truly fascinating. Now I want to read up further on steering models and how they're programmed. Steering feeling off is usually the thing that makes me hate driving cars in video games. Cyberpunk 2077 was the first time I felt like I was driving an actual vehicle.
I liked the talk, but it was given very much from the perspective of a game developer and not from the perspective of an engineer wanting to simulate a car. (Unsurprisingly)
There is actually a lot of literature on how to simulate vehicles, which would be quite a bit of help. He also mentions BeamNG whose approach is very weird if you actually want to get accurate vehicle dynamics. Their ongoing tire simulation project seems even weirder and as if it was done by people who actively tried to ignore standard approaches for modeling tires.
Programming vehicles in games
(wassimulator.com)285 points by Bogdanp 22 hours ago | 64 comments
Comments
This just reminded me of AngeTheGreat's incredible video series showing his engine simulator- absolutely worth checking out, considering it's optimized enough to run in real-time! The fact that he's simulating it well enough to generate realistic sound is absolutely mind-blowing.
https://www.youtube.com/watch?v=RKT-sKtR970
That’s the most important follow up. Without it, you’ll notice that the driving feels icy - I see it in the demo video. Most folks who fail to do the anti-roll bar and suspension wind up with cars that easily flip on turns - so they make the tires slip or they play with the surface friction, which makes the driving experience worse.
I made it in anger when I played a sidescrolling flight "simulator" on my phone in which the plane didn't behave anything like a plane! I figured "how hard can it be" and started learning a lot about how planes fly. It turned out there was a level of abstraction that was just right. Too unrealistic felt static and unsatisfying. Too realistic was difficult to calibrate for fun gameplay.
[1]: https://xkqr.org/flightle/
That's it! I also added skid particles. The drifting was achieved by playing around with the wheels and body damping. The game is here: https://apps.apple.com/app/drift-mania-infinite-car-racer/id...
Hamish Young, Vehicle Physics and Tire Dynamics in 'Just Cause 4' https://gdcvault.com/play/1026035/Vehicle-Physics-and-Tire-D...
Jan Erik Steel & Patrick Donnelly, Supercharged! Vehicle Physics in 'Skylanders' https://gdcvault.com/play/1023219/Supercharged-Vehicle-Physi...
Edward Pereira, The Science of Off-Roading https://dev.gdcvault.com/play/1024004/The-Science-of-Off-Roa...
Jared Cone, It IS Rocket Science! The Physics of 'Rocket League' Detailed https://www.gdcvault.com/play/1024972/It-IS-Rocket-Science-T...
On the other end of the spectrum, playing purely for fun with no regard for simulation or realistic anything ... I'll take a 1980s spinner wheel Super Sprint arcade cabinet any day for guaranteed smiles per mile.
https://www.arcade-museum.com/Videogame/super-sprint
It makes the case that cars in games offer a wide variety of unrealistic experiences and says this is unlike guns.
Is that really true? I've played games with homing bullets, slow projectiles, enormous projectiles, gravity guns, rocket jumping, hit scan guns, guns with bullet drop, freeze guns, ... idunno, I think there's a lot of variety in guns that are about the experience and not about simulating physics.
> It's because when it comes to cars, we derive our expectations of them not just from first hand experience. Our understanding of what “driving fast” feels like is often built from second-hand sources; films, games, pop culture.
And then this just feels like a theorycrafted thing with zero evidence. It's also even more true of guns than of cars, isn't it?
But then, there's stuff like, uh, jumping, where there is just as wide a variety in how you can jump in games even though my expectations about jumping come a lot more from actually jumping than do my expectations about driving come from actually driving.
Unreal Engine comes with two car demo projects. The first one is the "Hello World" of Unreal, and has a simple vehicle. The second one has an actual suspension model.
Disclaimer: I worked on Rocket League, but not on the game client.
Andre Marziali - Physics of Racing https://www.youtube.com/watch?v=bYp2vvUgEqE
A quick typo though: s/Imperically/empirically (I guess)
[1] https://github.com/omigroup/gltf-extensions/blob/main/extens...
I recall the Warthog and other vehicles actually defining some specific properties about vehicles like RPM and gear ratio, at least I think, because in first person you'd see some of those properties reflected in the dashboard of say the Warthog, or you'd hear it in the audio for a covenant vehicle.
But wow, man, what great feeling vehicles. Nothing else like it in the industry, in my opinion. The ridiculous feeling of vehicles in Grand Theft Auto 4 came really close, but those seemed to be much, much more detailed from vehicular motion and damage-taking perspectives.
There is actually a lot of literature on how to simulate vehicles, which would be quite a bit of help. He also mentions BeamNG whose approach is very weird if you actually want to get accurate vehicle dynamics. Their ongoing tire simulation project seems even weirder and as if it was done by people who actively tried to ignore standard approaches for modeling tires.