car slide

Started by
4 comments, last by hplus0603 16 years, 12 months ago
Hi, i am working on a car game. How can i apply a friction and slide the car?
Advertisement
How real do you want it to be? Best to have a good tire model first.
I remember reading a article on this somewhere, possibly on this site some where. On to the point, tires only have limit grip so at some point they stop gripping.

The tire can experience a maximum lateral and longitudinal fore, but when a tire is turning and de/accelerating it's maximum grip more than it can experience in one direction.

The maximum force it can take before losing grip is root(x^2 + y^2).

e.g. if the tire can experience a for of 10 during de/acceration and five during turning, the max force it can take is root(10^2 + 5^2) = root(125) = 11.8,

so you would need to check if the current forces on the tire dont exceed the maximum, so put the current x and y force into the equation and check against the maximum.

hope that makes sense
You don't have to explicitly model the sliding part, all you need is a friction force.
A simple equation is:

F = k*(v * L)/|v|

where:
- F is the friction force,
- v is the speed of the ground with respect to the tyre at the point of contact between the tyre and the ground,
- L is the load on the tyre (the force applied by the body of the car), and
- k is the grip coefficient (typically a value between 1.0 and 2.0).

v is typically equal to the speed of the center of the tyre projected on the ground plus the rotational velocity of the tyre multiplied by its radius.

This equation applies when the car is sliding, but as far as I can tell, it works well enough for a racing game in all situations but very low speeds (when starting up)

Real implementations are a bit more complex though. You compute two components of F, F_lat and F_long (in the frame of the tyre). Then the equation for each component remains the same, except that k is no longer a constant. Instead, k_long is a function of the slip ratio and k_lat is a function of the slip_angle:

F_long = L * k_long(slip_ratio)
F_lat = L * k_lat(slip_angle)

where:
- slip_ratio is -1.0 plus the angular velocity of the tyre multiplied by the radius divided by the speed of the center of the tyre (angular_vel*radius/speed -1.0)
- slip_angle is the angle between the tyre and the direction of the tyre

You can try k_long(0.0) = 0.0, k_long(0.05) = k_max, k_long(>0.1) = 0.75*k_max, k_max = 2.0 and k_lat(0.0) = 0.0, k_lat(6.0 degrees) = k_max, k_lat(20.0 degrees) = k_max * 0.75

See http://www.racer.nl/reference/pacejka.htm for more details about the curves.
-- Top10 Racing Simulation needs more developers!http://www.top10-racing.org
thx for your answers. But i mean when you turn the car quickly it slides. So :centrifugal force > N*k and it means: m*v*v/r > m*g*k
where:
m: mass
v: speed of the car
g: gravity
k: friction value
r: radius

But this formula works on circle road. I mean when you turn quickly how can i determine radius?
Car games typically simulate cars, by keeping various quantities about the car chassis (position, velocity, orientation and angular momentum, at a minimum). Sometimes, the suspension and wheels are simulated with similar quantities as well, and joint contraints are used to add shock/strut forces, keeping the wheels attached, etc.

When you do simulation like this, then steering just means swiveling the "forward direction" of your friction model away from the local front of the chassis. Swivel it more the more steering you get (if using mouse, joystick, gamepad etc).

The tire model will then apply forces to make the wheel want to move along its main forward vector, which may also apply torque to the simulated parts (call them "bodies"). For sideways slip, your friction model should just allow a bit of velocity in the perpendicular direction from the swiveled forward direction.

It's all about calculating forces and constraints, and doing integration. Once you build that system, most normal (and not so normal) car behaviors arise out of the simulation naturally.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement