Another topic on car simulation, guys ! First i must say thank you to all previous car question posters and the great people who helped them (like Kunos, K_J_M, and many others...). You are my heroes since i started to work on my racing game a few month ago ! I have to say i have read and recoded every single tutorial available on the internet and studied a LOT of car physics game source codes, including the ones posted here.

So, i'm developing this top-down racing game with semi-realistic physics where the main aspects are : having fun, nice skidding turns, and car parts looting/upgrading. So i need a credible model, not too realistic. Something with engine, torque curves, slip ratios, slip angles, a little of pacejka and newton physics seems perfect !

Everything is quite OK to me except the turning part, which is always tricky. I spent the whole week on this topic : http://www.gamedev.n...ation-headache/ and it helped me as much as it confused me !

Before explaining my problem in details and start asking what i may be doing wrong, i think the best is to ask for some clarifications about a thing or two that still confuse me (like conventions, and so).

So, my

**first question**will be about the tires longitudinal and lateral velocities used in the formulaes. It is the basing element everyone talks about and no one ever takes time to explain seriously.

Here are my assumptions about how to get those lat/long velocities :

- Start with the car local velocity
- Get world velocity of the car
- Get the world coordinates of the wheel you want to calculate things for
- Get the world velocity of this point (ie : the speed at wich the ground flies beneath that point)

THAT MEANS : if the car is not moving, but is spinning on itself, there IS a velocity for each tire in X/Y. I am precising this because this assumption of KJM confuse me :If we assume your car is stationary and points at 12 o clock with the front wheels centred, but is spinning on it's axis (yaw) then the wheels generate 0 slip angle because there is no long or lat linear velocities of the car.

- Convert the point velocity in car frame if necessary.
- FInd unit vector in front/side of the wheel, and rotate them according to steer angle of the wheels.
- The previous point velocity vector is projected on unit vectors to find front/side velocity.
- As i can't use the Length() method of my vector (which returns unsigned result), let say i rotate back the projected vectors of -steerAngle, so i can have the length directly with the x/y values.
- The X value of the projected vector on side is the lateral velocity (signed), same goes for the longit velocity with Y.
- Positive X means the wheel is moving to the right.
- Positive Y means the wheel is moving to the front.
- In order to be a side friction, the slipAngle must always be of the opposite sign of the lateral velocity of the wheel (after all the perpendical friction of the wheel does nothing besides slowing an already existing velocity, which in returns generate a cornering force allowing us to turn the car). Am i right ?

(friction is not enabled in examples so the car keep applying any force i gave initially)

I will use the front right wheel as base for calculations of velocities in the examples.

The formula i use to calculate slip angle is :

-Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity));I guess this formula is wrong. I could use this one from marcos tutorial, but i am totally confused with the omega things, because i think my method already takes angular velocity and steer angle in count before that step... Anyway this formula is different of mine or the one you can see in this topic. KJM and bmarci even ended using slightly different formulas.

**Example 1**: a car is heading front at 4m/s. The front wheels are steering at Pi/6 (30°). You can see a picture of it here with the different measured values and vectors as my simulation knows them :

I hope it is self-explanatory and explicity enough. You can see the values i found for the car X/Y velocity, the ones of the wheel after 30° steering and the associated slip angle (30°).

I think everything is ok until there, but if not, please let me know.

**Example 2**: now the car has no velocity but is spinning on itself. I made a video so it is easier for you to see what is happening i guess.

http://www.youtube.com/watch?v=UVDDYB-FDYI

**Example 3**: will be exactly the same thing as #2, but with the car being moving in a fixed direction AND spinning on itself. Remember, response forces are deactivated so the car is free to do crazy move. I'm just measuring values here.

In first case, the car is not moving fast enough forward before i apply the angular velocity, so the main friction force is here to slow down the car yaw

http://www.youtube.com/watch?v=O3-zo8oxvik

In the second case, the car has more velocity before starting to spin on itself, so the tire friction tries more to slow down the car. The lateral response vector (the great black vector coming out of the screen) change side accordingly to the car orientation and direction of travel.

http://www.youtube.com/watch?v=uiwiwxA4g5o

I noticed the black response vector sometimes switch side too late, when it reaches 6 o clock. It may be important or not, but i am sure to use the right tire coordinates, so may be more important as it seems ?

----

The examples i posted here seems to be OK to me, but when i try to apply the calculated forces, the car implodes because of too high constraints (sort of). It doesn't work. Actually, depending on initial heading of car, things happens differently... Which is odd and reminds me of the very first hour of my simulation when nothing was stable and was doing very silly vector/angle/physics engine miscalculations. For example, i use box2d which does not have the same coordinate system as my sim, it can sometimes be confusing.

Before going further into the problem and the questions i may have, i was wondering if someone could have a look and says if something seems really wrong or if it seems ok until there.

Any help will be much appreciated ! Thanks !!!

Raphael

**Edited by PochyPoch, 09 September 2012 - 08:22 PM.**