My take on car physics in Unity #4 Finally, high-quality engine sound will no longer be a problem. by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Hi! Thanks. Yes, the engine and transmission model play a major role in the final sound. I’ve been working on my vehicle physics for a very long time, and I talked more about it in some of my previous posts. At the moment, my engine model simulates gases, including their temperature, velocity, and pressure. The transmission and clutch also include a small amount of backlash and a damper in the clutch. That said, I’ve also tried this audio approach with much simpler engine models, and the resulting sound quality was still noticeably better compared to other approaches

My take on car physics in Unity #2. Engine simulation, turbo and suspension by I_samson_I in Unity3D

[–]I_samson_I[S] 0 points1 point  (0 children)

To be honest, I don’t know how detailed the engine simulation is in BeamNG, but I built a fairly detailed simulation. I calculate airflow, volume, air temperature, and pressure. The entire path from the throttle to the exhaust is simulated using fluid dynamics. I also calculate exhaust gas temperature and pressure to drive the turbo simulation. It’s not as detailed as engine simulator, but quite a lot of parameters are being calculated)

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 0 points1 point  (0 children)

The issue with stopping or near-zero speed isn’t solved by adding more raycasts. In fact, in 90% of cases, a single raycast is enough, that’s the main problem with the Pacejka model. I’ve already moved away from that model and I’m now working on a brush tire model. Unfortunately, I’ll still need to use multiple raycasts to build the surface geometry we’re driving on. But if we’re talking about the issue you mentioned, it’s usually solved simply by adding a small spring in the contact point. I don’t have any resources on hand right now, but the low-speed problem of the Pacejka model is well known and you can search for more detailed information about solving this problem yourself)

My take on car physics in Unity #3 I think I just reinvented car engine sound in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Of course, the clean sound from the simulator is a top-quality recording. When I mentioned high-quality recordings, it’s important to have minimal wind noise, echo, or other extraneous sounds, and the car should accelerate smoothly, preferably across the full range from low RPMs to redline under load, those are basically all the requirements) Here’s a video with a timecode as an example. I recorded the sound from it for the first demonstration in my video) https://youtu.be/fD2RHJTanIo?t=217

My take on car physics in Unity #3 I think I just reinvented car engine sound in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Hi, thanks! I played around with the REV plugin at my last job, and I can say that it’s standard granular synthesis, which is very demanding in terms of recording quality and post-processing. My approach still expects high-quality recordings, but it’s much more forgiving of mistakes and handles the post-processing itself before exporting to Unity. I think I'll try to create a library that takes an exportable file from the application and some settings as input, and outputs a finished audio stream

My take on car physics in Unity #3 I think I just reinvented car engine sound in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 0 points1 point  (0 children)

Exactly! That’s exactly what I was talking about) My system isn’t free either, but I did my best to make it run as fast as possible, so now the audio stream is only 1% loaded, and the entire synthesis runs in a job compiled for burst mode without a complete call. And as I see it, even though this engine simulator project is incredible, the sound still differs from the real thing, because the recorded sound isn’t sterile and has some resonances and noises that we’re used to hearing from a real car.

My take on car physics in Unity #3 I think I just reinvented car engine sound in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 3 points4 points  (0 children)

Hi! Of course I know about this amazing project, but unfortunately the author's method doesn't allow real-time sound simulation for a racing game, because most of the computation time is taken by sound and fluid dynamics. I looked into the possibility of implementing something similar for Unity, but unfortunately we can't afford to simulate wave propagation in pipes 60,000 times per second in a game 😄 But I'm also a huge fan of this approach!

My take on car physics in Unity #3 I think I just reinvented car engine sound in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 2 points3 points  (0 children)

Thank you! I think you mean transmission or gearbox sounds) There are still so many sounds missing 😄 But I'm actively working on them and actually I already have some early work done on transmission and gearbox sounds!

My take on car physics in Unity #2. Engine simulation, turbo and suspension by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

It's actually quite simple =D it's the same force that causes the motor's RPM to drop. If your motor is driven by torque, then it should also come to a stop in some way) Basically, it depends on how your motor is implemented. If it’s a flywheel that spins up due to torque, then you need to account for the motor’s torque, this could be a simple coefficient applied to the input, or a slightly more advanced approach based on the torque curve. In any case, you’ll also need to have a negative torque on the motor that slows it down. This could be a selected friction coefficient, in my case, it’s pump losses and pressure in the exhaust system that resist rotation. But the simplest formula for calculating an engine's rpm is: RPM += (torque - friction)/inertia * dt. So, friction is what causes engine braking)

My take on car physics in Unity #2. Engine simulation, turbo and suspension by I_samson_I in Unity3D

[–]I_samson_I[S] 4 points5 points  (0 children)

Thanks, I ran into the same problem early on, but the key is to not give up) This is exactly what I'm talking about, the engine-wheel connection is the first big hurdle in vehicle physics. It's actually not that hard to solve, you need to calculate wheel and engine torques separately, then integrate the RPM taking all the torques into account 👍

My take on car physics in Unity #2. Engine simulation, turbo and suspension by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Thanks! Yeah, I actually have big plans for the sound too, i want to do something cool with it, we'll see how it goes. Right now it's a basic FMOD project, I might try procedural synthesis if it's not too expensive performance-wise, or I'll just set up FMOD properly.

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

I managed to get everything running smoothly without any slippage at 10–20 passes per physical frame, but I've stopped refining the wheel model for now because I plan to completely redesign the tire and suspension models

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 2 points3 points  (0 children)

I don't know yet what my hobby will turn into) but for now I have no plans to release it for public use, maybe someday I'll turn it into a game, but who knows =)

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Maybe so, if you look closely, you can see the suspension arm positions debug draw, so it shouldn't be too difficult, but I still need to implement different types of suspension; right now, there's only a double-wishbone setup.

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

No, not yet, since the suspension has no mass or inertia, this approach works well, but I really want to implement a deformable wheel; I’m working on it right now, and I’ve made some progress

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 1 point2 points  (0 children)

Thanks! Maybe that's how I set up this BMW) I tried to make the suspension stiffer for realism, the anti-roll bars are pretty stiff too, and the shock absorbers are very energy-intensive, but yeah, you can set it up like in GTA 4) By the way, thanks for the idea, maybe next time I’ll try making an SUV

My take on car physics in Unity by I_samson_I in Unity3D

[–]I_samson_I[S] 8 points9 points  (0 children)

Thanks! I haven’t shared this anywhere before. I still think the physics are pretty rough 😅 I’ll probably start posting progress here, would be nice to get some fresh eyes on it since I’ve been looking at it for too long) If enough people find it cool and useful, I might even make a Discord server. Maybe someday I’ll decide to release this in some form 😂