   Tire grip in top-down car dynamics
  I'm stuck at simple 2D car physics for my game, i can now calculate velocity of each tire in car's local space, so i know if the car is sliding sideway and the lateral / longtitudal velocity of each wheel axis point, now i need to somehow apply tire friction force that applies tire grip and engine breaking (when it is not accelerating), which would hold the car stable when turning, what is this formula called? i was thinking it must be a rolling friction joint, can someone direct me at some websites that deals with this in some easy way?  Regards, Jernej L.    
  look at the pacejka formula. There is a recent topic about it.   ;Quote:Original post by oliiilook at the pacejka formula. There is a recent topic about it. What exactly does pacejka formula do? it appears to be something very complex. [Edited by - Delfi on September 9, 2007 2:15:17 PM];  In a nut shell, Pacejka's formula calculates a longitudinal (forward) and lateral (sideways) force.http://www.racer.nl/reference/pacejka.htmhttp://phors.locost7.info/contents.htm (parts 22, 23, 25, 25, and 29)   ;  Thats what you need to do, calculate forward and side forces and apply a friction model.For starters you need a 2d physics integrator. Such that you could make a physically accurate pong game. A moveable body (the ball/the car) needs an AddForce(Vector RelativePosition, Vector Force) function. This will both apply the force to the body to generate an acceleration and also apply a torque about the center of mass.Next you need to create 4 force generators for your vehicle body. These will simulate the tires on the ground. So each physics iteration you'll calculate the wheel forces on the vehicle and apply them.Pseudo code for this process:for(int i = 0; i < 4; i++){    Vector wheelforce = new Vector();    //calculate slip vel at wheel point    Vector point = wheels.GetRelPos();    Vector sideDir = wheels.GetEffectiveAxel();    Vector sideVel = vehicle.GetVelInDir(point, sideDir);    //20.0 is an arbitrary friction constant    //a more complex model can be added here    Vector sideForce = -sideVel * 20.0f;//oversteer    if (superDrift && i > 2) //i>2 for front wheels   sideForce *= 2.0f;    //if a side forces exists, apply it    if (!float.IsNaN(sideForce.length))   wheelforce += sideForce;    //add friction model projected onto forwardDir    vehicle.AddForceRelPoint(wheelforce, point);}The reason you query the effective axel vector from the wheel, which in my demo is really a joint, is that if the wheel turns for steering. The effective axel for the front wheels will rotate producing a force towards the center of the turning circle.   ;  I'm using newton physics engine in my game, but i limit vehicle rotation to stay top-down, newton uses a euler integrator (believe it or not... ), but my game is limited to 30 FPS (for easier netsync), which would mean i don't need a integrator in my game for these calculations?  So, from what i understand, pacejka formula works like this, you send it the local point velocity of a tire and tire friction, and it returns you "sideways" forces to apply which makes the car magically behave realistically?  So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution?? ;Quote:Original post by Delfi... which would mean i don't need a integrator in my game for these calculations?If you're using newton's integrator then no, you don't need your own integrator. You simply need to calculate these forces per physical simulation step. But of course you need some kind of integrator in this situation (Newton in your case).Also, all integration techniques come down, in the end, to a Euler integration. How you obtain your derivatives is a different story.Quote:Original post by Delfi So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution??Each wheel has a velocity at the contact patch. This is the velocity you compare to the world velocity to calculate the contact velocity. If it's zero, there is absolutely no slip (regardless of the vehicle speed).So when you want to brake, you simply start reducing the velocity of the contact patch (slow the wheel down). This will cause a difference in the world/contact velocity and induce a force (acceration is this in reverse). If you pull the hand brake the wheels velocity relative to the vehicle is instantly zero'd. So if the vehicle has any velocity, the world/contact velocity will jump up and a huge force will be introduced at the locked wheel.   ;Quote:Original post by bzroomQuote:Original post by Delfi... which would mean i don't need a integrator in my game for these calculations?If you're using newton's integrator then no, you don't need your own integrator. You simply need to calculate these forces per physical simulation step. But of course you need some kind of integrator in this situation (Newton in your case).Also, all integration techniques come down, in the end, to a Euler integration. How you obtain your derivatives is a different story.Quote:Original post by Delfi So how does pacejka work with car acceleration, breaking, and handbrake powerslides and weight distribution??Each wheel has a velocity at the contact patch. This is the velocity you compare to the world velocity to calculate the contact velocity. If it's zero, there is absolutely no slip (regardless of the vehicle speed).So when you want to brake, you simply start reducing the velocity of the contact patch (slow the wheel down). This will cause a difference in the world/contact velocity and induce a force (acceration is this in reverse). If you pull the hand brake the wheels velocity relative to the vehicle is instantly zero'd. So if the vehicle has any velocity, the world/contact velocity will jump up and a huge force will be introduced at the locked wheel.So brake only applies longtitudal forces, and not lateral, and this makes it lose control & make it able to do powerslides?  ;  I like to think of it as two complete separate models. If the wheels on your car could roll in any direction. There would be only one model. But since it can only roll in the longitudinal direction, you have a sideways no roll model, and a forward/reverse roll model. The side no roll model is always the same regardless of input, the only thing that changes is the direction the side force acts when the wheels are turned for steering.The forward/reverse model is the only one that is affected by braking and acceleration. It's not even the model that changes, its the input "relative velocity between tire and ground".If you use a proper static/kinetic friction model this will enable proper power sliding. If you use a faked friction model like I demonstrated, you'll just have sliding. If the relative velocity between the ground and tire is zero (this is true any time you don't hear squealing from your tires, regardless of speed). Then you'll use the static friction model. Once static friction is exceeded, you'll switch to the kinetic friction model for both directions. So once your engine torque breaks the wheels free, there is instantly less friction in both directions. This is a power slide.   