#### Archived

This topic is now archived and is closed to further replies.

# The physics behind skidding...?

This topic is 6041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi there, I''m currently developing a primitive 3D racer, and I''ve come to the point where I need to implement some physics...I am tackling the problem through some lateral thinking, but I''m hoping that someone out there can save me some time by pointing me in a particular direction! Any thoughts will be greatly appreciated! Thanks for listening, Tin

##### Share on other sites
Well I don''t know how realistic you want your skidding to be, but the basic idea behind it is this:
When a car is going in a direction that is not parallell to it''s wheels (in a turn for example) the car will not only undergo forward/backward wheel friction, but also sideward wheel friction. The thing is that this sideward friction is a lot higher. (Try to move a toy-car sideways across a table with it''s wheels on the table.)

Now what you do, is you decompose the car''s velocity vector into a forward vector and a right vector. Then you apply different friction on each of these and put it back into the velocity vector.

Here''s some C++ish 2D pseudo code (I''m asuming you know some basic vector math):
  // angle is the car''s orientation in radians// velocity is the car''s 2D velocity vector// fric_sideways is the total amount of sideways friction// fric_forward is the total amount of forward/backward friction// construct the forward and right vectorsvector2d forward, right;forward.x = cos(angle);forward.y = sin(angle);right.x = cos(angle+PI/2);right.y = sin(angle+PI/2);// determine how much the velocity consists of forward and right motionfloat forward_amount = DotProduct2D(forward, velocity);float right_amount = DotProduct2D(right, velocity);// calculate total frictionvector2d friction;friction = forward_amount * forward + right_amount * right;// apply the friction to the car''s velocityvelocity -= friction;// NOTE: you''ll probably want to multiply by the amount of time elapsed since last frame (for framerate independant motion)// like this://velocity -= friction * delta_time;

This is all from the top of my head so there might be errors in it. But I hope this gets you started.

##### Share on other sites
Hey thanks!

I just looked through my Game Dev. mags and found a good article that covers exactly what I''m looking for...but your ''solution'' has certainly simplified the problem for me!...I always had a sound theory, but couldn''t think how I could put it into code...

One (very naive) question about your code though: You mention a "right" vector...will I need a "left" one aswell?...or will a general "sideways" vector (like you mentioned in the comments section of your code) suffice?

thanks again...

Tin

##### Share on other sites
You only need one vector to represent the sideways motion of the car - the "right" vector can represent movement to the left if its magnitude is negative.

##### Share on other sites
Of course...thanks

##### Share on other sites
Sorry about the confusion. But Krunk helped you out just fine. Anyway, here are some ideas for you on how to extent to this basic algorithm: Apply the forward and right friction to each of the wheels seperately and on the car's body as well (air friction). Hold the wheels and the car's body together with springs. This produces some rather neat effects. Just make sure you create realistic (read: believable) frictional coeffecients (sp?) for the different tires and car bodies.

EDIT: one more thing, in my first post I did a simple
velocity -= friction * delta_time;
but friction is actually a force, so it should be:
velocity -= (friction / carMass) * delta_time;

And if you go with the more realistic method above, use tireMass and bodyMass and such.

Edited by - Scarab0 on December 31, 2001 6:43:19 PM

##### Share on other sites
How would you handle the actual skid, i.e. once you start leaving visible tread on the pavement? I assume you switch coefficents of friction, but how do you decide when to switch?

##### Share on other sites
Darn, I noticed another flaw in my pseudo-code. right_amount and forward_amount should be multiplied by some frictional coefficients. Otherwise the friction will be too large or too small.

quote:
Original post by LilBudyWizer
How would you handle the actual skid, i.e. once you start leaving visible tread on the pavement? I assume you switch coefficents of friction, but how do you decide when to switch?

Once abs(right_amount) gets beyond some specified value, the tires will leave skid marks. I don''t really know why though. I guess the frictional force exceeds the tire''s structural integrity(sp?).

##### Share on other sites
quote by Scarab0:

Once abs(right_amount) gets beyond some specified value, the tires will leave skid marks

the tires would also leave skid marks if forward_amount was far enough away from the actual speed of the tires. couple quick examples: ex. car is going forward but tires are locked up (braking). ex2. car is going backward and tires are spinning forward.

- jeremiah
http://fakemind.com

##### Share on other sites
quote:
Original post by fakemind

the tires would also leave skid marks if forward_amount was far enough away from the actual speed of the tires. couple quick examples: ex. car is going forward but tires are locked up (braking). ex2. car is going backward and tires are spinning forward.

Yes you''re quite right. So maybe skidding for tire number i should be determined by the length of the vector: car.velocity - car.tire.velocity?

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631778
• Total Posts
3002308
×