Automobile Physics - Drifting

Started by
5 comments, last by dfacchin 17 years, 9 months ago
Hi guys, I am working on a racing game project which looks awesome so far, I am just a bit concerned how to calculate the drifting factors of the car. Aside the drift physics of the car, my physics engine worx pretty much flawless. TIA for answering. Best, M.Z.
Advertisement
The biggest challenge for a physics-based driving sim is the wheel+tire simulation. If you already have a reasonably accurate tire simulation, setting up the car as a drift car should give rise to the proper behavior. Look up drifting websites to find spring+damper rates, swaybar settings, tire pressure, weight distribution, etc.

For my simulator, just giving the car high HP and modulating throttle through a turn generates reasonable drifting behavior. In order to hold and throttle control a drift while holding significant counter steer, either the car will have to be set up just right (will take practice to set up as well as drive, just like in real life), or artificial torques will have to be applied to make it easier for players to enter and hold a drift (most common option).

Artificial torques are much easier to set up and control, but ultimately won't feel as natural has having the system exhibit proper behavior from generalized physics. However, if there are significant time constraints, just getting it done with artificial torques is good enough for arcade style sims (fun is the most important factor, not realism).
On a related note, let us suppose that someone (for example, me) wanted to do a racing game, but did not want to do the fairly involved work required to implement a mostly physically correct vehicle simulation. Are there any good libraries out there?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Promit- the closest thing to a library for doing driving games is ISI's gMotor(1|2) engine, which is used in rFactor, GTR, GTL, GTR2, etc. This engine appears to be a 2D engine with respect to vehicle motion: yaw movement is reasonably realistic, but pitching and rolling movement does not appear to be 3D (strange things happen when the cars leave the ground, a 'bobble head' effect is seen from external views, as if the rolling chassis is anchored to the ground and the body/shell is mounted on a (bobble head) spring).

This apparent simplification works well enough for hard-core simmers to enjoy games based on this type of engine. It appears that this concept is used in many other driving games (such as Project Gotham Racing, Gran Turismo, etc.), as dealing with and controlling a 2D simulation is easier to manage than a full 3D simulation. This concept can even be used when cars leave the ground frequently: just switch to a 3D simulation when the car is airborne, then switch back when the car is on the ground.

It's not clear if they license their engines, but Live for Speed and NetKarPro appear to try to simulate a full 3D rigid body and multibody springs. When simulating multibody springs for a car, the combined spring and damper forces for the tires (which act like springs and dampers) and shocks become quite stiff. Numerically, the equations also become stiff, and the springs and dampers must be oversampled to provide stability: LFS appears to sample at 1000Hz, NKP @ 500Hz. They both appear to use either a basic Euler integrator, or a Newton-Stormer-Verlet variant (where velocity is updated before position, providing more accuracy and stability). I'm fairly certain no one is using Runge-Kutta or similar higher order integrators: Euler/Semi-Implicit-Euler/NSV at high sample rates appears to be the most stable/accurate/efficient/popular.

Given the stiffness of the shock-tire system, using an implicit integrator would seem like a natural option. An implicit integrator could probably run as low as 30Hz and remain 100% stable. However, I would guess that even at higher sampling rates (60, 120), an implicit integrator would low-pass filter the resulting motion, removing some of the desired 'bumpiness' which helps to make a driving sim feel more realistic (bumpiness could be added back in, similar to the 'bobble head' method, by jittering the car/camera based on track surface and car velocity).

http://www.iracing.com (NR2003/ex Papyrus) and http://www.driversrepublic.net/ (RBR dev) will also have good physics-based simulators; not clear if they will license their engines.

Racer, a free (for non commercial use) simulator, appears to use a 3D simulation (uses ODE for physics); source code is also available (just downloaded the lasted (binary) version; drives reasonably well. Source code is for an earlier version (no source for current version). Lots of useful info including Pacejka (tire curve) editors, etc. While Pacejka curves are useful for static tire analysis, the big challenge in making a driving sim feel real/playable is dynamic tire behavior (not aware of any published data for racing tires; appears to be well protected/hidden by the tire manufacturers). The path to more realistic dynamic tire behavior appears to be through so-called 'brush' models for tires (expensive to compute in real time). I use a hybrid constrained spring model which works OK so far (will make more brush like as time permits in the future).

Looking at the Racer/ODE source code should provide the basic idea of what it takes to get a physics-based driving sim up and running. Getting realistic dynamic driving behaivor takes time (especially if realistic drifting is desired!). Depending on the target market, it might make the most sense to follow ISI's (apparently) 2D approach and/or use helper torques to get the car to behave as desired.
Thank you all for all the useful replies you've made. Alas, I don't think that I might be able to use the engines as the licensing info is obscure in a way. Anyhow thank you for your time, and please if you have any other method to get over this problem, don't hesistate to post it. Thank you very much.


Best,

Milad Zarpak
A good first step is to have reference material to check your simulation against. Check out these videos (pretty funny, but should be useful):
http://video.google.com/videoplay?docid=1450816463147850231&q=drifting

Found this online: http://www.driftgame.com.au/

Gran Turismo drifting (appears to be a 2D physics sim): http://video.google.com/videoplay?docid=-2949067658360696662&q=drifting.

Many more on [google] videos.

The easiest solution after basic driving is possible in your sim, is to program the appropriate yaw torques to make the car drift in the same way as seen in the real/toy car videos (and GT4, etc.). Throttle steer: reduce rear grip and increase forward thrust with increased thottle, do the opposite on reduced throttle (more effect during throttle transitions, including braking transitions). Solving the problem in this manner (in 2D) is much simpler than trying to get a (generalized) 3D simulation to generate the correct behavior (though you could apply the yaw torques and specialized tire thrust to a 3D sim).
Both Newton and Physx are physix engine for game with specialeced classes to add car physics in few steps.
They are good if u don't need an accurate simulation, but just and easy implemantation for cars. If u are not looking for a real simulator this can be good chioces.
There is a project going on that is call Motorsport, give a look at that one too, it's opensource.

This topic is closed to new replies.

Advertisement