## Recommended Posts

Rapha    158
Hi to everyone !

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 : [url="http://www.gamedev.net/topic/630058-vehicle-simulation-headache/"]http://www.gamedev.n...ation-headache/[/url] 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 [b]first question[/b] 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 :[list=1]
[*]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 : [quote]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.[/quote]
[*]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 ?
[/list]
A few examples to make sure i understand everything on this definition of frontal/lateral velocities :

(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 : [CODE]
-Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity));
[/CODE]
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 [url="http://www.gamedev.net/topic/630058-vehicle-simulation-headache/"]this topic[/url]. KJM and bmarci even ended using slightly different formulas.
[img]http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games_files/ct_alphas.gif[/img]

[u][b]Example 1[/b][/u] : 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 :
[img]http://img836.imageshack.us/img836/7931/forward4mpssteerright30.jpg[/img]

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.

[b][u]Example 2[/u][/b] : 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.

[u][b]Example 3 [/b][/u]: 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

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.

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

##### Share on other sites
K_J_M    401
Hello PochyPoch.

I havn't read all of your post but a quick glance brought me to question 4.

To clarify Part 4.

If the car is stationary and spining on it's axis, and the front wheels arn't turned to any steering angle (yaw) but pointing in the direction the chassis points, then each wheel generates +- 90 degrees slip angle. The wheels only have lateral movement. ie they are only sliding sideways as the car spins.

The sign of the slip angle depends on whether the car is spinning clockwise or anti clockwise.

My statement about not generating slip angles was because the car is stationary and no slip angles are generated from the code that uses linear velocities of the car chassis to determine the slip angles. My basic method was using 1 wheel (chassis) to determine the slip angles and Bmarci was using 4 wheels.

Slip angles are generated by the difference between the longitude and lateral velocities of the tire.

The confusion comes from the fact that i was using the car chassis to determine the slip angle and not for each tire.

So when writing your sim, you need to take into consideration the angular velocity of the car and the slip angle that generates for each wheel and the linear velocities of the wheel (chassis , since the wheel is attached to the chassis).

The car can be moving with no angular velocity (moving forwards or sliding sideways), stationary but spinning on it's axis or any combination of the two.

And both situations need to be considered to determine your actual slip angle for each wheel.

The steering angle of the front wheels also needs to be taken into consideration for the front wheels slip angle.

Hope thats clearer.

And best of luck with your game.

I too have made a top down racer.

[url="http://www.trinosis.com/"]http://www.trinosis.com/[/url] Edited by K_J_M

##### Share on other sites
Rapha    158
Hi, K_J_M !

If i understand you, then a static but spinning car would generate velocities for tires that would be with 0 longitude, and some value in x depending on the direction of rotation. Something like that : [url="http://en.wikipedia.org/wiki/Uniform_circular_motion"]http://en.wikipedia....circular_motion[/url]

I found it to be true if the tire is aligned with the radius of the circle. As the wheels are not centered, but rather on the side of the car, when they are not steering, then the radius from wheel attach point to car CG will not be perpendicular to the wheel heading.

If you draw a path following the front right wheel positions, it is indeed a perfect circle, and the velocity of that point (blue vector) is indeed tangent to circle. But as my wheel is not aligned with the radius, the projection of the velocity according to steering (wich is 0), will give me both lateral and frontal velocities, wich in turn will give me a slip angle not equal to +/- 90°. The only case i have such results is if :
a) There is only 1 front wheel, centered on the chassis (like a bike, or tricycle)
b) The wheel is aligned with the radius coming from CG
c) The car is sliding lateraly

[img]http://img834.imageshack.us/img834/8581/circulatpath.jpg[/img]

That is a little confusing to me, so i am wondering if :[list=1]
[*]I should have 0 longitidunal velocities as long as the tire is describing a circular path, regardless of wheel steering. The steering would then be "used" in slip angle calculation like the formula from marco suggest it :
[CODE]
slip = Atan(latVel / |frontVel|) - signOf(frontVel) * steerAngle
[/CODE]
[*]I should have a longitudinal & lateral velocities (excepted for previous a,b,c cases) and my calculations are OK until there (the wheel front/lat velocities are the green and red vectors on the picture).
[/list]
I am suspecting it is not the only thing that goes wrong with my simulation but it would really helped me to know which way is the right one [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

And again, thanks for your help, it is much appreciated ! Edited by PochyPoch

##### Share on other sites
K_J_M    401
It seems to me you are looking at the issue with regards to world coordinates.

If you look at the issue with regards to local car coordinates then each wheel has 0 longtitude velocity and (N) Lateral velocity if the car is spinning on the spot.

Marco Monsters car physics tutorial performs the world to local coordinates transform by rotating the linear world velocities by the yaw angle of the car / wheel.

s = Sin(yaw_angle)
c = Cos(yaw_angle)
local_lateral_velocity = (world_x_velocity * c) + (world_z_velocity * s)
local_longitude_velocity = (world_x_velocity * -s) + (world_z_velocity * c)

And to transform back from local to world coordinates. ( Note the sign for the sine command is reversed, which reverses the direction of rotation )

world_x_linear_velocity = (local_lateral_velocity * c) + (local_longitude_velocity * -s)
world_z_linear_velocity = (local_lateral_velocity *s) + (local_longitude_velocity * c)

But in regards to a stationary car spinning on it's axis the lateral wheel velocity is derived from the car angular velocity. Edited by K_J_M

##### Share on other sites
bmarci    786
Hi PochyPoch,

Here are some remarks that helped me to get it, if not even right, but an acceptable result
1. Create transform functions between coordinate systems (World, Car, Wheel) and double check if they produce the wanted results.
2. Calculate everything in its own coordinates, eg: wheel forces in wheel space, car forces in car space...etc
3. Forget about steering angle in slip angle/ratio calculations. If you have the right transform functions, that will take care of steering angles.
4. Check the result of the ATAN(lat/long), especialy when dividing by long=0!!! The result should be +-PI/2

This is my transform from WORLD to WHEEL, in case of velocity:

angle = -car_yaw_angle-wheel_steer_angle
sn = sin(angle)
cs = cos(angle)
vel_x = cs*world_vel_x + sn*world_vel_y
vel_y = cs*world_vel_y - sn*world_vel_x

(X+ right, Y+ forward/up)

In the last video of your original post (around 0:20) I see something like: timestep = 50/1000
Be careful with this large timesteps, it can cause stability problems with integrating.

I hope I didn't confuse you too much

##### Share on other sites
Rapha    158
Hello to both of you !

I worked very hard those past days on the simulation, and made some progress.

@K_J_M & @bmarci
[quote]If you look at the issue with regards to local car coordinates then each wheel has 0 longtitude velocity and (N) Lateral velocity if the car is spinning on the spot.[/quote]
That is right, but when i look at a point in a system, i use my pointVelocity method which takes angVel in account like you said
[quote]But in regards to a stationary car spinning on it's axis the lateral wheel velocity is derived from the car angular velocity.[/quote]
So, theorically, when spinning on itself, any point velocity depends on angular velocity of the car. That velocity will be tangent to rotation circle and depends on distance to CG. The wikipedia page illustrates this very well : [url="http://upload.wikimedia.org/wikipedia/commons/2/2f/Velocity-acceleration.PNG"]http://upload.wikime...cceleration.PNG[/url]

So i have something like that :
[img]http://img837.imageshack.us/img837/6290/pointvelocity.jpg[/img]

So, now, what bmarci said is exactly what i'm doing :
[quote]1. Create transform functions between coordinate systems (World, Car, Wheel) and double check if they produce the wanted results.
2. Calculate everything in its own coordinates, eg: wheel forces in wheel space, car forces in car space...etc
3. Forget about steering angle in slip angle/ratio calculations. If you have the right transform functions, that will take care of steering angles.
4. Check the result of the ATAN(lat/long), especialy when dividing by long=0!!! The result should be +-PI/2[/quote]

That's exactly the way i do things. So that means, i am transforming the point velocity of the wheel (the blue vector on the picture) in wheel coordinates, which as we can see it on the picture will result in both lont/lat velocities, and so in a slip angle which is not 90° when the car is spinning on itself.

So the conclusion is in contradiction with what KJM stated above, but i can't see what is failing in my reasonment. Am i right to not find 90° for a wheel which belongs to the right place on a car spinning on itself ? The point velocity seems good, so if i am supposed to get only lateral velocity, i need a sort of hack, or maybe stay in car coordinates instead of going into wheel system ?

The thing is, i am almost sure i am right on this and that my slip angles are good, because the wheel produce good damping forces to annihilate car angular velocity when spinning on itself. If tires produce 90° slip angles when the car is spinning the car is slowing down of 99% and not 100%.

If my slip angles are good, that would mean that my car problems during cornering lies somewhere else. As i said i have obtained a better result, but i am not sure if my base calculations in slip angles are OK. So i cannot really try to tune pacejka or other things like wheel velocity and weight transfer if the underlying system is not good.

Actually the result i have is very close to the Java source example you can download on marco's website. It seems ok as i have deactivated everything else : weight transfer, decreasing pacejka curve, no more real engine/wheel transmission / rotation. I needed to have a clean working table, sort of.

But when i try the car on my game track it is far from playable. If i use an always increasing, producing high cornering forces curve for lateral pacej, then the car turns very sharply, and i can have somme controled oversteer, but the car will eventually stop in the turning curve instead of keeping some speed.

If i use a realistic pacejka curve, then the car is understeering at high speed, which is good, because i can do high speed turns in a comfortable way. But, if i want to produce oversteer and drift for a sharper curve, it just doesn't happen.

So, what do you think ? Problem in base system calculation ? Pacejka curve tuning ? Maybe i should reactivate some critical feature or system ?

I will try to cast a video of the car later to show try to show you, if interested.

Thanks for your help, my game really needs it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Sorry for the long posts by the way...

EDIT : the main thing here, might be this "the car will eventually stop in the turning curve instead of keeping some speed".

I have the feeling that when i take a sharp turn, even if a great part of the initial velocity will be killed by the lateral forces, and even without pushing throttle, the car should keep more front velocity to come out of the curve. Instead it just stops there with very small to none forward velocity. If i could have this, and manage somehow to mix the best of the 2 results i have with my different pacejka, the game would start to be fun i think.

EDIT2 : those results were obtained with a dummy traction circle (allowing 2*weightLoad traction max), applied only on lateral force for testing purpose. Edited by PochyPoch

##### Share on other sites
Rapha    158
Oh, and i have one more question that has haunted me those past days.

Knowing that marcos slipAngle formula is made to be used with car coordinates (that's why it takes angular vel, and so) to determine the lateral force the tire produce, it makes sense that this lateral force should be applied to the car directly perpendicular at wheel position.

But, i use a formula where the front/lat velocities are the real ones of the wheel. So, simply using this formula should work to determine slip angle : [CODE]
var alpha = -Math.atan2(wheelRealSideVelocity, Math.abs(wheelRealFrontVelocity));
[/CODE]

But when it comes to applying that lateral force...
Case 1 : Should i apply the given force perpendicular to wheel, with steering producing an oriented lateral force, which will slow down the car ?
Case 2 : Or instead should i apply it perpencular to wheel attach point, regardless of steering, and then it will only make the car turn, but never slow it down ?

Case 1 example :
[img]http://img546.imageshack.us/img546/1576/lateralforceappliedonti.jpg[/img]

Case 2 example :
[img]http://img267.imageshack.us/img267/1834/lateralforceappliedonbo.jpg[/img]

Everyone use its own formula and coordinate system in the examples i have found, so it is not clear to me.

For Slip Ratio, it is more obvious as we look at patch speed (wheel angular velocity) and ground speed in the direction the wheel is heading, it seems logical to have that vector acting in the wheel space, thus respecting steering angle.

But using a simplified formula with examples were it is used to apply a force directly perpendicular to car makes me have some doubts... Edited by PochyPoch

##### Share on other sites
K_J_M    401
Hi.

The Pacejka formula's work in wheel local coordinates.

Longtitude pointing in the direction the wheel rolls in and Lateral at 90 degrees to Longtitude direction.

So,as i understand it, Case 1 Example is correct.

Although i'm no expert, i always understood that a stationary car spinning on the spot with the steering centred produces no longtitude forces from the tires to move the car forwards or backwards. But only lateral forces to slow down the rate of spin.

But, maybe someone with more detailed knowledge than me can give a more accurate explanation.

##### Share on other sites
Rapha    158
Hi,

That's bad for me because i get much better results applying the lateral force directly to car chassis regardless of steering angle (but i take it in count for slip angle calculation). Maybe i just need to tune pacejka curve to respond to the fact it changes the car behaviour somehow. A little change alway seems dramatic in result at first, but maybe it is the right way to go and i need to adapt my curves which are really trivials for now.

[quote]Although i'm no expert, i always understood that a stationary car spinning on the spot with the steering centred produces no longtitude forces from the tires to move the car forwards or backwards. But only lateral forces to slow down the rate of spin.[/quote]
As i understand it, when wheels are centered, the lateral response will be perpendicular to wheels, and will then slow down car rotation, but it will not introduce longitudinal force. The longitudinal force component present on the wheel during spinning will just introduce a diffrent slip angle result.

I re-checked marcos page for the steering section. He claims, after determining lateral force using pacejka curve, that they have to be applied to the car body. He will apply both lateral forces directly to car body, and then use them separatly to calculate torque and finally introduce some yaw. Fine for me, but what does he have to say about the lateral component of the front wheels ? This :
[quote]The lateral forces of the four tyres have two results: a net cornering force and a torque around the yaw axis. The cornering force is the force on the CG at a right angle to the car orientation and serves as the centripetal force which is required to describe a circular path. The contribution of the rear wheels to the cornering force is the same as the lateral force. For the front wheels, multiply the lateral force with cos(delta) to allow for the steering angle.[/quote]
[CODE]
Fcornering = Flat, rear + cos(delta) * Flat, front
[/CODE]
I'm quite rusted with my trigonometry, so i'm not 100% sure, but i think that will act as if the lateral response IS indeed perpenducular the the wheel, according to steer angle, BUT that he is suggesting to take only the force component that is projected on the car side axis. So if the front wheels are centered, 100% of the force will be applied. But if the wheel is steering at 60°, only 50% of the force is applied to the car.

But he is only calculating centripetal force and torque, so i guess only the truly lateral component does it. He may have "forget" the sin(dela)*Flat, front which is supposed to slow down the car as it is cornering, but maybe it is not that important for the car behaviour ? If i release the gaz pedal, it may slow down the car by a similar amount. If i'm right, that would mean, that i just should try to have better steerAngle/steerSpeed/lateralCurves constants instead of looking at the maths.

---

One other question as i'm experimenting if i may :

Do you know if traction circle should be applied before or after taking count of weight load ? Because when i slow down the car in/before curves, so much weight get transfered to the front that the lateral force increase happens way too fast and the car can make an half-turn really easily. I feel like traction circle should be capped at some maximum load or maybe my weight transfer needs a real spring instead of a simplistic time integration of the weight transfer.

By the way, it feels a bit strange to me that only weight transfer due to +/- acceleration affects cornering capacity in curves. Am i missing something here or again, should i just tune weight transfer speed to get something smoother to drive ?

[b]EDIT [/b]: after re-reading closely PHORS articles, it seems only acceleration/weight transfer affects available traction and it is supposed to scale linearly with weight load, indefinitely. http://phors.locost7.info/phors07.htm

---

Thanks for your help and sharing your experience ! You say you are not expert, but given the quality of your racing game, i'll take your advices very seriously ! It's exactly the kind of feeling i want, only more arcade-ish. Edited by PochyPoch

##### Share on other sites
K_J_M    401

Both Long and Lat Pacejka formulas need FZ (load) as one of the inputs.

And a resulting force as output.

The traction circle caps the forces to a maximum limit. I think the Racer sim reduces Longitude forces in favour of Lateral as a way to cap the forces.

But there are several different methods that i've seen.

Since the traction circle limits forces, and these are calculated from Pacejka which requires FZ (load) as an input, the traction circle caclulations are applied after the forces have been calculated.

##### Share on other sites
bmarci    786
[quote name='PochyPoch' timestamp='1347494865' post='4979521']
As i understand it, when wheels are centered, the lateral response will be perpendicular to wheels, and will then slow down car rotation, but it will not introduce longitudinal force. The longitudinal force component present on the wheel during spinning will just introduce a diffrent slip angle result.
[/quote]
I would argue with that. In your post #6, the blue arrow IS the real velocity of the tyre, which is perpendicular to the vector from CG to wheel pos, but not to the wheel's heading.
So it WILL generate both long/lat forces. If you do the same calculations for the remaining 3 wheels the sum of all Fx's will be zero if the CG is at the center of the car, so that's why there is no movement of the car body.

[quote name='PochyPoch' timestamp='1347494865' post='4979521']
I re-checked marcos page for the steering section. He claims, after determining lateral force using pacejka curve, that they have to be applied to the car body. He will apply both lateral forces directly to car body, and then use them separatly to calculate torque and finally introduce some yaw. Fine for me, but what does he have to say about the lateral component of the front wheels ?
[/quote]

Since Marco is using only two wheels (front/back) his lateral forces are always tangential to "yawing circle", with centered wheels. If you are thinking in more wheels, this is mostly not the case.

What worked for me is:
1. Calculate long/lat forces for each wheel and create a force vector of them, VForce = {lat_force , long_force} in WHEEL space
2. Transform VForce to the WORLD space (as an ordinary 2d verctor) and add them together for all wheels (so you have a total 2D force vector acting on the car body)
3. Using the Car's mass you will get the acceleration and thus the velocity in WORLD space. acc=ForceTotal/Mass
4. For rotation, transform the VForce to CAR space, and -here comes the tricky part- split the VForce_InCarSpace vector into 2 components. One is perpendicular to the (CG->WHEEL) vector and the other one is parallel
5. You'll need the one that is perpendicular, get some idea from here: [url="http://en.wikipedia.org/wiki/Vector_projection"]http://en.wikipedia.org/wiki/Vector_projection[/url]
6. Multiply the resulting force component by the wheel distance from CG and you get the torque that the wheel aplies to the body around the CG
7. Sum all torques and with ang_acc=TorqueTotal/BodyInertia you get the yaw angle acceleration of the car body

[quote name='PochyPoch' timestamp='1347494865' post='4979521']
Do you know if traction circle should be applied before or after taking count of weight load ? Because when i slow down the car in/before curves, so much weight get transfered to the front that the lateral force increase happens way too fast and the car can make an half-turn really easily. I feel like traction circle should be capped at some maximum load or maybe my weight transfer needs a real spring instead of a simplistic time integration of the weight transfer.
[/quote]

The weight load is an input parameter to the tyre model as well as slip ratio and slip angle, if you want to cap the result to the limit you have two options (I've found so far)
1. The most typical way is to cut down the resulting forces (Fx/Fy), you can perform single vector scaling or prefer one over the other (eg: use all the long_force and use as much from lateral as much remained in the traction budget)
2. The other one that works me the best is to cut down the input parameters (slip angle/slip ratio) See chapter 24/25 of PHORS.

##### Share on other sites
K_J_M    401
"
I would argue with that. In your post #6, the blue arrow IS the real velocity of the tyre, which is perpendicular to the vector from CG to wheel pos, but not to the wheel's heading.
So it WILL generate both long/lat forces. If you do the same calculations for the remaining 3 wheels the sum of all Fx's will be zero if the CG is at the center of the car, so that's why there is no movement of the car body.
"

Thanks for the explanation Bmarci. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I see there were flaws in my understanding.

I was assuming that a stationary car spinning on the spot has zero linear velocities and as a result no slip angles could be generated.

But in fact, you show that although the car chassis has no linear velocites, the wheels actually do and therefore the slip angles can be calculated whilst ignoring the angular velocity of the chassis.

Sorry for any confusion pochypoch.

##### Share on other sites
Rapha    158
Hi again !

Thank you so much for your detailed answers. I reinvestigated and rechecked every thing you said to me since the beginning, and each time i gain confidence on the fact i'm going the right way, so thanks again. It is very good to be able to say "now i dont have a doubt on the way i do this, anymore, so lets move on" [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

@bmarci
Thanks for explaining so clearly. I tried your method over mine (i calculate force/torque for each wheel right away rather than summing), but as expected it gives me the exacts same results. So i guess my calculations must be good there.
[quote]I would argue with that. In your post #6, the blue arrow IS the real velocity of the tyre, which is perpendicular to the vector from CG to wheel pos, but not to the wheel's heading.
So it WILL generate both long/lat forces.[/quote]
I agree, but i deactivated slip ratio, wheel angular vels around axle and any braking/acceleration force to simplify my steering behaviour research. I just apply 1*weightLoadOfCar/4 to the powered wheels for the moment. So in my case it will be only lateral forces generated right ?

@both
Thank you for explaining your way of using traction circle. I personnaly was ploting my curves for a normal load, applying traction circle (by croping excedent force) and then multiply by the load. The final result should be the same, but anyway i deactivated this feature right now.

I think i really need your expertise to help me search the right way, because all the maths and physics we reviewed together seems ok everywhere. I have rewritten and triple checked all physics / maths functions. I "hope" i am wrong on this, but everything really seems ok there.

So i would say the problem relies more on the car handling side of the problem.

I have tweaked a LOT of parameters recently, and i can offen "sense" the same defaults in almost every configuration i tried.

My general feelings are :[list]
[*]Car seems way too much sensitive, or the total opposite. Controled drift are impossible due to very fast changes in car orientation
[*]Car seems to acquire way too much angular velocity, too fast
[*]Each time a wheeltrain acquires some force it will happily make my car oversteer/understeer dramatically fast
[*]Quite offen, if i go fast enough and start to oversteer in a long controled slide, small changes (gaz/brakes/steer), will cause the car to violently change heading to realign with velocity trajectory (almost instant), or to realign with previous oversteer heading.
[*]Car will easily spin, and then continue to travel backward
[*]Applying full lateral vector to front wheels when steer angle is near 30° will result in extreme car slowing
[*]If i have 5% more lateral traction in front wheels, the car will spin almost everytime !
[*]Dividing torque by 2 or 3 makes it better but still not perfect
[*]It is almost impossible to have the car at 30°, sliding laterraly and to control the slide movement by changing acceleration or steering. Again, things seems to happen too fast
[*]Very important thing i think is that the car will rarely slide laterally for a long time, as there is alway a force (front or back) that is higher and will make the car to align with direction vector one way or the other very fast
[*]Car is not unstable or jittering, i test all kind of situations, and the response it gave me seems always appropriate, only way too violent / not enough controlable
[/list]
Those results are with :[list]
[*]No traction circle
[*]No weight transfer
[*]1ms time step, which is small enough AFAIK
[*]Deactivated wheel angular velocity, slip ratio and engine (only dumb front force when i press forward)
[*]Drag/Air resistances (constants multiplied by worldVel or worldVel² to have some damping), very negligeable
[*]Regrouped wheels to middle of car (no X), as it changes almost nothing in behaviour, to avoid eventual calculation errors
[*]Car mass : 1500Kg
[*]Car Weight / Tire : 3700
[*]Car inertia : 700
[*]Car CG is centered, front wheels are 2m front and back wheels 2m back
[*]Car total length is 4m
[*]Pacejka lateral curve is like this :
[/list]
[CODE]
this.slipAngle = [0, 1.0, 3.0, 5.0, 9.0, 11.0, 20.0, 30, 40, 50, 60, 90];
this.lateralForce = [0, 0.7, 0.9, 1.0, 1.1, 1.15, 1.20, 1.15, 1.1, 1.0, 0.9, 0.80];
[/CODE]

When i compare this to your racing game K_J_M, (first i am telling me that it is a very nice game you have made ^^), and then the first car available in demo seems to gain some +/- angle easily, then it slides a little to prevent lateral motion, and it seems really soft and smooth. I can use all parameters i want, i still not have succeed to have this kind of nice feeling.

My point of comparison are recent casual games (like death rally), the KJM racing game, my game when i use non-realistic physics to try to have a nice behaviour, and ultimately games like GT, Grid or NFS series. So from most arcadish to most realistic, i still miss a big something to make my car controlable as those games do.

For your implementations, as soon as you had lateral pacejka and base the base physics right, did you managed to create a fun, controllable car right away ? Or did it recquire some more hacks/forces downscaling or real physics features stuff (like front slip ratios) to allow for controled drifting ?

For example the small demo you shared on the "car headache" thread started by marci, if i remember correctly, you apply angular velocity right away as we press left/right. And you scale the lateral pacejka to front speed, too ? Is it because the demo is simple, or is it because it just works better that way ?

I'm shooting a video or two to try to illustrate the fact the car behaves quite good until it spins, and the "trajectory auto-realign" stuff i was talking about.

I look at my samples again and again, but my intuition gives me nothing on this, i feel like i have the basics right and i have tried changing almost every value i have here and here without enjoyable results...

[b]Video 1 : [/b]You can see in the second curve the weird alignment thing i was talking about.
Front / Rear lateral forces are the same.
Interesting values on the chart. Last run in slow motion.
All others parameters are as i have explained above.
Except for that, i can have some controlled drift with a linear slipAngleInRad * someConstant force output.

[b]Video 2 :[/b] An oversteer manoeuver with the pacejka curve i posted just above.
The front lateral force is 5% higher (multiplied by 1.05).
Along the video i am varying various parameters (lateral output magnitude, trying to accelerate in cornering to help, setting front/rear lateral force to equal, or back lateral to 95% of front).
It demonstrates that very few parameters variation can cause very fast spin vs. successful cornering. No controlable drift with those parameters...

##### Share on other sites
K_J_M    401
Hi.

For my Autocross Racing game i used lateral Pacejka coeficients similar to this curve.

[img]http://www.trinosis.com/files/lateral_pacejka_curve.jpg[/img]

This gives a very forgiving tire with a lot of grip at all slip angles.

I noticed in your second video that your car reaches a maximum slip angle before it loses grip and spins around.
This is classic of a Pacejka curve that peaks at a small slip angle.
once past this peak, the tire has no grip and the car spins around.
Altering your Pacejka curve so it looks similar to mine above should help prevent this and allow for drifting.

You should be able to get variable car handling from using different curves. The Racer sim for instance uses different coefficients for front and rear tires.

But specifically for my game, i just rotate the cars velocity vector by the lateral Pacejka force to give that arcade drifting feel.

It's not physically accurate in any way and i did have to tune various attributes to get the correct feel i was after.

In theory, a physically accurate sim should be able to produce a wide range of handling for a car from an arcade drift feel to a simulation mode, by altering such things as the Pacejka curves, engine power, gear ratio's ect.

But in practice creating an accurate sim is going take a long time to do (particularly because theres very little information available on the subject), so it comes down to priorities.

If your priorities are to get an arcade game written as quickly as possible then i see no reason in hacking together an arcade sim, which is exactly what i did for my game.

If on the other hand you want to write a physically accurate sim and then use that as a basis for games, then it will take a long time to get right.
You could use a third party car physics engine and i know some general purpose physics engines support wheel physics and suspension constraints (Newton physics engine for example) , so that may be an easier route for you. Edited by K_J_M

##### Share on other sites
Rapha    158
Hi again

Thank you for sharing your experience with me (and other readers if any).

[quote]But specifically for my game, i just rotate the cars velocity vector by the lateral Pacejka[/quote]
Mmm, i have some trouble to picture that... You rotate car world velocity vector, from an angle you determine with the normalized lateral force ? Like 1 output = 1 radian rotation for velocity vector ? I'll try that kind of stuff to see the results !

EDIT : i missed this precious piece of knowledge :
[quote]I noticed in your second video that your car reaches a maximum slip angle before it loses grip and spins around.
This is classic of a Pacejka curve that peaks at a small slip angle.
once past this peak, the tire has no grip and the car spins around.
Altering your Pacejka curve so it looks similar to mine above should help prevent this and allow for drifting.[/quote]
Thanks ! I'll try that right away [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[b]In your understanding, the controled drifting would occur after the peak (on the descending curve), or rather on the ascending part, before reaching the peak ?[/b]

[quote]In theory, a physically accurate sim should be able to produce a wide range of handling for a car from an arcade drift feel to a simulation mode, by altering such things as the Pacejka curves, engine power, gear ratio's ect[/quote]
That's what i think too, but it takes indeed quite a long time. The idea is to create a game that allows you to choose from a large variety of parts and even vehicule types. So having a nice basic simulation seemed a good idea. It still is, but we also need to have results as fast as possible. The game will be long term (web-based), so we will continue to investigate and work on the simulation until it produce satisfying result

Ultimately we will want a large variety of game modes so having a rich simulation will also help to achieve that goal.

[quote]For my Autocross Racing game i used lateral Pacejka coeficients similar to this curve.[/quote]
I remember ploting one of my curves on this one recently [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] I even re-used your pacejka formula from your demo source, but the result differ for the last part even when all previous results were the same as yours, i haven't really looked into this issue, so right now i use some simple dots. Oh and the 1164N output force (peak) for a small 1N load input confused me too. But i still can inspire of the general shape.

---

So i guess from now on, i'll try to homebrew some sort of hack to make the game fun, as we would like to release a test version tomorrow.

On the long-term, i think i'll have to find for myself what kind of feature is too violent, what is the acceptable range of effect of weight transfer, wheel slip, etc, and to find some physically not-wrong ways to stabilize the whole thing.

I guess that realistic traction circle, with fine pacejka and 4 wheels weight transfer can produce an interesting result, only if the impact of each system does not exceed a few %.

The ultimate goal is to be able to set any type of parameters and still be able to drive the car. We would like a game where players are able to change everything in the car. So we sort of rely on physics for the itemisation of car parts, as we'd like it to be random instead of predefined stages or prebuilt cars. So you could remove a truck tire to put it on a race car if you want, but the game has to produce something that provides both a physically logical effect and fun driving.

I guess we still have a very long way to go,then !

[quote]If your priorities are to get an arcade game written as quickly as possible then i see no reason in hacking together an arcade sim, which is exactly what i did for my game.[/quote]
Well, i will go that way for now, thanks for the advice, it is well appreciated, and as i said i willl then try to stabilize the basics of the car physics to support a more wide range of configuration in the future.

[quote]You could use a third party car physics engine and i know some general purpose physics engines support wheel physics and suspension constraints (Newton physics engine for example) , so that may be an easier route for you.[/quote]
Well the game will be full HTML5, so we can look at other libraries, but nothing exists out of the box. That's why we work so hard on this, it is like a challenge ! Maybe i'll buy [url="http://www.edy.es/dev/vehicle-physics/live-demo/"]this one in Unity[/url], and look at the source code to see what i can use. When i [url="http://www.edy.es/dev/2011/12/facts-and-myths-on-the-pacejka-curves/"]read this article[/url], it makes me want to ask a lot of questions to that guy ^^

The demo is quite convincing to me, with both realistic/arcade cars.

---

Thank you so much to both of you for your time and helping me, and if it is not too much asking, (and your interest / work on the subject continues), i'd like to keep you informed of what i do next in the thread.

Let's try to get something fun ! Edited by PochyPoch

##### Share on other sites
bmarci    786
[quote name='PochyPoch' timestamp='1347579187' post='4979887']
were the same as yours, i haven't really looked into this issue, so right now i use some simple dots. Oh and the 1164N output force (peak) for a small 1N load input confused me too. But i still can inspire of the general shape.
[/quote]

The Pacejka MF, takes KILO NEWTONS as input load, so your 1N is actually 1000N!

I was twiddling with stability and controlled drifting and such in the weekend and realized that the weight transfer has significant importance in cornering and control, which makes sense, but also confuses me why anti-roll bars help stabilizing in corners.

Without weight transfer my car was incredibly unstable at high speed (>100km/h), even with a very small (2-3°) steering angle it spun around instantly.
Adding some load transfer helped, but it was still oversteer without throttle. With throttle it was just understeer, but no inbetween... So I cannot play with brakes and throttle to control drifting.

My weigth transfer formula is:

W=m*GRAVITY
Wf=(c/L)*W-(h/L)*Fx
Wr=(b/L)*W+(h/L)*Fx

For 4 wheel weight transfer, I'm not sure if this is the right thing to do:
Just transfer along axles based on lateral acceleration.

Fz_front_left=0.5*Wf+(h/Track)*Fy
Fz_front_right=0.5*Wf-(h/Track)*Fy
...the same for the rear wheels...

Fx, Fy - Forces acting on the car's body in car space
c/b = Axle distance from the CG
h = Height of CG from ground
L = wheelbase
m = Car mass
Wf, Wr = weight on front/rear axle
Track = Distance of wheels on the same axle

Adding some jacking force helps a bit, but still not the result I expected.

F_jack=Fy*h_roll_center/(Track/2)
Fz_front_left-=F_jack
Fz_front_right+=F_jack

h_roll_center = roll center height from ground

Maybe I'm mixing up things, or should I implement a proper suspension model, where all spring and dumping forces do all the weight transfer and the formula above is not needed at all?

I was also playing with car settings, and it seems a front engine car (60:40 weight balance to the front) is more controllable than a mid-engined (40:60) which should not be.

##### Share on other sites
Rapha    158
Hi !
So i guess the new subject is "how to make it both physics-based and and fun", eg : have some sort of NFS cornering style. Or at least GT with a very controlable car.

[quote name='bmarci' timestamp='1347874246' post='4980823']
The Pacejka MF, takes KILO NEWTONS as input load, so your 1N is actually 1000N!
[/quote]
Thanks for the precision

[quote name='bmarci' timestamp='1347874246' post='4980823']
I was twiddling with stability and controlled drifting and such in the weekend and realized that the weight transfer has significant importance in cornering and control, which makes sense, but also confuses me why anti-roll bars help stabilizing in corners
[/quote]
Yes, i realized the same thing. I have come to the conclusion that physics-based car SHOULD implement some sort of weight transfer, as ultimately every force get scaled by weight transfer.
For anti-roll bars, their main effect should be to prevent the car to roll in high speed cornering ; in 3D physics, if you generate a lot of lateral forces during cornering, the car inertia makes it want to roll : http://www.euclideanspace.com/threed/games/examples/cars/cornering/car2cornering.png
I think from a 2D point of view, that anti-roll bars will help to prevent too much weight to go left/right of the center of mass during cornering too, which can have some effect in tires grip. Altough, i have read, lateral weight transfer is generally a good thing, as it gives more grip to the tires who needs it. But it must become a bad thing past some critical ratio value i guess.

What i can tell you is what i know (almost) for sure abour car control. In a so primitive state as we are, the things that would tend to have the more effect on the driving feeling would be :[list=1]
[*]The wheel friction (long/lat, etc)
[*]The wheel springs (weight repartition entirely relies on them)
[*]The control system intelligence (without intelligence even a very fun/arcade car might be unplayable without very carefull throttle/steering management from the player)
[/list]

I feel like we are more at step 1. Successfully going to step 2 might be quite complex, and maybe we should do some arcadish algorithms to handle weight transfer and its effects the way we want it before blindly implement yet another "real life" physics formula.

I realized those past days that input post-analyzing is maybe even more critical that correct lateral/long forces implementation. If you look at almost every car game, at high speed the wheel is steering of 2-3° against 45° at very low speed. Some games calculate the peak of lateral grip to prevent the player from going besides grip peak. Same goes for front/brake inputs.

It's not ESP or anti lock system at this point, it is more like the driver "listenening" to what the car he is sitting in has to "say". I'll try to come up with some formula to calculate max steer angle in real time to see how much it helps during cornering.

[quote name='bmarci' timestamp='1347874246' post='4980823']
Without weight transfer my car was incredibly unstable at high speed (>100km/h), even with a very small (2-3°) steering angle it spun around instantly.
[/quote]
What kind of lateral friction do you apply ? Because i tend to have some sort of controled lateral drift quite easily with :
a) no weight transfer
b) a linear force returned for cornering forces : slipAngleInRadians * 5 for example (with a 1500kg car, so it is around 3500N for each tire)
[media]http://youtu.be/z_6tRGwShFE[/media]
I shooted this video to show you what i am saying.

Without weight transfer, i tend to have this behaviour when the lateral forces curves & weight load are == for the 4 wheels. With "real" pacejka curve, i get a lot of understeer after the peak, so i have to limit the steer angle of the wheel.

Sorry for the low framerate it is actually smooth and nice to see (no teleporting). I'm recording with VLC which gives me a not that good framerate.

---

Adding rear/front (no lateral) weight transfer i get :[list]
[*]Great instability if turning + braking. Note that braking occur naturally because of front wheel lateral friction, "natural" air/roll friction, + eventually real driver input braking. Anyway, my car spins really fast even with a very small amount of weight transfered from the rear to the front.
[*]Increased understeer effect during high speed cornering, especially if i do not limit steer angle.
[*]Theorically controled drift could happen, but in reality car spins way too fast for the driver to have any time to react. Even in slow motion, if you have time to react, the situation evolves too quickly. But the physical facts & consequences are not illogical to me.
[/list]
---

I don't know if my experience is helping or confusing you. (helping, i hope).

I remember using 5% more traction (linear *1.05 multiply) for front or rear wheel train, successively. More grip to rear = understeer and more grip to front = oversteer. Nice to play with without weightload, but as soon as weight get transfered it makes turning even more catastrophic.

My intuition here tells me, the great yaw velocity comes from the lack of balance between front/rear tires lateral response. *1 or *10k is not very important as long as everything scales at the same time. If the lateral force balance comes to F70%/R30%, for example, the car will do spin turns very fast.

When i analyse those ratios at the times the car seems to be in a small oversteer situation (which is a feeling players tend to like), the front wheels quickly (almost instantly) goes from 90% to 51% of the total generated lateral forces in early cornering. If you want to prevent the car to spin, the lateral force of the rear wheel must quickly go over 50% to keep the car heading controllable (in the above video example, the rear wheels go to 51% of the total lateral force generated to "counter" oversteer). So, looking at the problem from this perpective might help you to adjust parameters to stabilize things. It helps me to think clearly at "what i want", anyway.

I know we can use different traction circles/curves for front/back tires, but i have seen very nice drifting behaviour in Edy's car physics which seemed to apply the same curves for every wheel. So i would (will) try to get drifing whithout messing with this for now.

---

Actually i am wondering if lateral weight transfer could greatly influence the wheels in the outside of the turning lane, in a maner that would add more stability to car yaw, and eventually help us to get a nice turning feeling. What is your feeling about this ?

---

[quote name='bmarci' timestamp='1347874246' post='4980823']
Adding some load transfer helped, but it was still oversteer without throttle. With throttle it was just understeer, but no inbetween... So I cannot play with brakes and throttle to control drifting
[/quote]

Same thing here. Worse : if i try to limit traction circle to have throttle/braking to allow for controled drift, i go from normal high speed understeer (due to high speed, despite small deceleration) to instant oversteer because throttle consume too much traction budget. I have the feeling i want the 100% operating range of my drifting to be limited to a very small range of force difference.

Looking at Edys vehicle physics curves in real time, i learned you can saturate front wheels without starting to spin instantly. I still have to figure out if that is dued to springs, more complex formulas, or to input control and magic things.

---

[quote name='bmarci' timestamp='1347874246' post='4980823']
My weigth transfer formula is:
W=m*GRAVITY
Wf=(c/L)*W-(h/L)*Fx
Wr=(b/L)*W+(h/L)*Fx
[/quote]

Here is mine , it looks to be the exact same. Anyway, weight transfer is quite easy to check from real life data available on internet. The problem does not lie in the raw calculations rather in the fact that spring must have a great influence on that, too (i guess).

[spoiler][CODE]
// Gravity center height
var cgHeight = this.car.cg.h;
// Distance between front/rear axle
var distanceBetweenAxles = this.car.cg.b + this.car.cg.c;
// Distance between actual wheel and gravity center
// TODO : calculate REAL distance (wheels are not centered in axles, rather on the car sides, so we should use pythagore)
var distanceToCenterOfGravity = 0;
if (this.wheelId == WHEEL_FRONT_RIGHT || this.wheelId == WHEEL_FRONT_LEFT) {
distanceToCenterOfGravity = this.car.cg.c;
} else if (this.wheelId == WHEEL_REAR_RIGHT || this.wheelId == WHEEL_REAR_LEFT) {
distanceToCenterOfGravity = this.car.cg.b;
}
// We need ratio cgHeight/distanceBetweenAxles to calculate mass transfer
var h_by_L = cgHeight / distanceBetweenAxles;
// Mass of the car
var totalCarMass = this.car.m_mass;
// Planet gravity
var NEWTON_GRAVITY_CONSTANT = 9.81;
// Weight of the car on the planet
var totalCarWeight = totalCarMass * NEWTON_GRAVITY_CONSTANT;
// Static wheel load (without acceleration)
var staticLoad = (distanceToCenterOfGravity / distanceBetweenAxles) * totalCarWeight;
// Dynamic load due to car acceleration
var dynamicLoad = h_by_L * totalCarMass * forwardAcceleration;
// Taking care of acceleration sign for weight increase/decrease
if (this.wheelId == WHEEL_FRONT_RIGHT || this.wheelId == WHEEL_FRONT_LEFT) {
// Front wheels get less weight with more front acceleration
}
else if (this.wheelId == WHEEL_REAR_RIGHT || this.wheelId == WHEEL_REAR_LEFT) {
// Front wheels get more weight with more front acceleration
}
// The weight was for the axle, now we devide it by 2 for individual wheel weight
[/CODE][/spoiler]

---

[quote]For 4 wheel weight transfer, I'm not sure if this is the right thing to do:
Just transfer along axles based on lateral acceleration.
Fz_front_left=0.5*Wf+(h/Track)*Fy
Fz_front_right=0.5*Wf-(h/Track)*Fy
...the same for the rear wheels...[/quote]

I was going to do the same thing. You can indeed get lateral weight transfer the exact same way you get front/rear. The problem is you have 2 differents values for 4 wheels, so it is 8 values. How do you combine that ? I was thinking about this :

For example :[list]
[*]static load = 3500N / wheel
[*]front/rear load = 4000N front / 3000N / rear (decelerating)
[*]left/right load = 5000N left / 2000N right (high speed turning)
[*]i think we SHOULD take care of angular velocity in lateral weight transfer, but i haven't looked into it.
[/list]
So, laterally 42% of weight goes from right to the left.
And 15% of the weight goes from rear to front.

I would say it give me for the different tires :[list=1]
[*]FL : 3500 + 3500 * (+0.42 + 0.15) = 5495
[*]FR : 3500 + 3500 * (-0.42 + 0.15) = 2555
[*]RL : 3500 + 3500 * (+0.42 - 0.15) = 4445
[*]RR : 3500 + 3500 * (-0.42 - 0.15) = 1505
[/list]
Total weight = 14.000N, so =3500*4. I think this way the weight is what it is supposed to be. In my example, i have way more lateral acceleration than front deceleration, so the outside wheels should get way more grip with some oversteer due tu front having more traction.

I think those weight repartition values would produce very unstable car (yawspins), but i'll try it anyway.

---

[quote]Adding some jacking force helps a bit, but still not the result I expected.

F_jack=Fy*h_roll_center/(Track/2)
Fz_front_left-=F_jack
Fz_front_right+=F_jack
h_roll_center = roll center height from ground[/quote]
I'm not entirely sure how/why it helps, what do you mean by jacking force exactly ? I know it has something to do with suspension, but i havent really looked into in ATM.

I tried to divide weight transfer valye by 250, 500, 1000 to simulate "time to reach the calculated weight", it helps, but still, weight transfer has dramatic effects on behaviour.

---

[quote]Maybe I'm mixing up things, or should I implement a proper suspension model, where all spring and dumping forces do all the weight transfer and the formula above is not needed at all?[/quote]
I really don't know, and i really want to know ! As i said, suspension seems to be a critical part of how a car can be handled.

---

[quote]I was also playing with car settings, and it seems a front engine car (60:40 weight balance to the front) is more controllable than a mid-engined (40:60) which should not be.[/quote]
Be sure you are using the proper wheel distance to CG. If i have more weight to the front, the car easily align the front in the turns. Even when CG is only closer to front of a few cms, the effect is immediatly noticeable. As with traction, even a few % changes have great consequences.

AFAIK, front engine cars are easier to handle, as they can easily turn compared to rear-mounted engines car which can be tricky to handle during oversteer situations as the back of the car want to go to the front (easier car spins). So i guess you're experiencing something which is good.

But with unstable car turning due to a few % changes in repartion of mass, if you are braking with a front mounted engine, you will obtain even wore oversteering.

---

In facts, all those things leads me to think that my main problem is the effects so small ratios changes are producing. Dramatical effects. Everything should be WAY more stable even with poor wheels/suspensions systems.

So the right question is what should i do (maths shortcut or real physics) to improve my car stability... ?

My currently strategy is :[list]
[*]Intelligent analysis of player inputs (ideal max steer angle/throttle ...)
[*]Gently decreasing force when coming closer to traction circle edge (when i'll re-introduce it)
[*]Try lateral weight transfer to if it improves/worsens car handling during high speed turns
[*]Maybe add a "time to build up" to generated forces. I have read, in reality a tire can take 250ms to really produce the max force it can bring. But i'm afraid it will do counterbraking and such things totally impossible to handle.
[/list]

Extreme measure i might try if results are not good enough in a few days :[list]
[*]Directly rotating velocity vector of the car in some situations (i have to define situation+angle, help can be brought by KJM as it seems he is doing it in his game)
[*]Limitating max torque / angAcc / angVel of the car
[*]Artificially prevent car spins (eg: if rear wheels go to 55% of lateral force + the car has some important yaw velocity, introduce some mechanism that would stabilize it)
[*]Limit weight transfer to a VERY small ratio
[*]Use a linear pacejka curve
[/list]
I guess i'll have to implement proper springs/suspensions, but at this point i am not even close to measure the impact it would have on my simulation (good/bad, or more probably good, but not enough to make the game fun).

I'm very interested by your experience and future answers [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by PochyPoch

##### Share on other sites
bmarci    786
[quote name='PochyPoch' timestamp='1347890951' post='4980876']
I realized those past days that input post-analyzing is maybe even more critical that correct lateral/long forces implementation. If you look at almost every car game, at high speed the wheel is steering of 2-3° against 45° at very low speed. Some games calculate the peak of lateral grip to prevent the player from going besides grip peak. Same goes for front/brake inputs.
[/quote]
Yes, I made a speed sensitive steering which seems to work fine until some heavy intervention is needed, so if my car starts to skid my steering doesn't let me to counteract because of the high speed, and there is only 2-3° of max steering available.

[quote name='PochyPoch' timestamp='1347890951' post='4980876']
What kind of lateral friction do you apply ? Because i tend to have some sort of controled lateral drift quite easily with :
[/quote]
I use lateral pacejka. The mentioned uncontrollable situation occurs without my special addition.
Earlier I added an extra Vel_long-=wheel_roll_vel; to the contact patch velocity calculation (only for slip angle) since the wheel rolling also affects the contact patch's velocity.
So with that little extra the car is very stable at least on a straight move with lane changes. Maybe it's an "arcadish" tweak for better handling, but without it I have hard time having the car move on a straight line after a little direction change (A simple overtaking is a great challenge, the car is moving off the road and it's a pain in the ...... -somewhere- to put it back on the road again.)

[quote name='PochyPoch' timestamp='1347890951' post='4980876']
Actually i am wondering if lateral weight transfer could greatly influence the wheels in the outside of the turning lane, in a maner that would add more stability to car yaw, and eventually help us to get a nice turning feeling. What is your feeling about this ?
[/quote]
I made a quick force calculations on lateral traction vs. weight transfer; (and noticed some weird result values, see later)

No weight transfer: (steer angle=1°)
Fz_left=3kN
Fy_left=937N
Fz_right=3kN
Fy_right=937N

That's 1874N total lateral force on the front wheels.

With weight transfer, same steer angle (75%R 25%L)
Fz_left=1.5kN
Fy_left=970N
Fz_right=4.5kN
Fy_right=745N

That's 1715N total lateral force which would mean the lateral weight transfer is bad to the stability???
Also my pacejka curve looks good when I display it, but in the last values more load generates less lateral force? I don't get it. Is that normal?
Could you check it with your formula? The error in my theory is probably somewhere at the two wheels don't have the same slip angle at steering.

[quote name='PochyPoch' timestamp='1347890951' post='4980876']
Quote
For 4 wheel weight transfer, I'm not sure if this is the right thing to do:
Just transfer along axles based on lateral acceleration.
Fz_front_left=0.5*Wf+(h/Track)*Fy
Fz_front_right=0.5*Wf-(h/Track)*Fy
...the same for the rear wheels...

I was going to do the same thing. You can indeed get lateral weight transfer the exact same way you get front/rear. The problem is you have 2 differents values for 4 wheels, so it is 8 values. How do you combine that ? I was thinking about this :
[/quote]
I meant, "the same method for rear wheels"

Fz_rear_left=0.5*Wr+(h/Track)*Fy
Fz_rear_right=0.5*Wr-(h/Track)*Fy

It's basicly the same as what you did (divide the load to front/rear based on Fx, and divide each axle's weight to left/right based on Fy).

Maybe I should buy that steering wheel, which would instantly point out if the problem is in the simulation or in the controls

##### Share on other sites
bmarci    786
I just got an idea:

Maybe it's time we started using the aligning moment (Mz) from our favourite Pacejka formula

I'll try to integrate it into the simulation, so if everything works as I expect the wheels should go back to 0° when I let loose the steering wheel (when moving).
And maybe use steering torques as the drivers hangs on the steering wheel and thus at the peak moment the steering and aligning forces should cancel each outher out.

Does it have any sense or absolutely pointless?

I added mouse steering, so any steer angle can be produced instantly. Very unconfortable, but the skidding is much more controllable.

##### Share on other sites
bmarci    786
An other note about stability. Since my car has 60% load on the rear axle, I played with the pacejka coeffs for the rear wheels so now they produce more lateral traction and thus more stable and eliminated the sudden oversteer, just a bit more grip as you mentioned.
BUT!
Now I cannot skid, not even with handbrake, also donuts work only with nose-weighted cars.
So now I have almost everything but they don't work together. If I reduce grip on the rear tyres I can make the parking-lot-show-off-manouvers but cannot take the first corner on the track. Soon I'm gonna be out of ideas.

##### Share on other sites
Rapha    158
Hi, bmarci !

I apologize for the long response time, but unfortunately, despite my best efforts, i had not that much interesting answers to bring.

The best progress i made so far was realizing front/rear weight transfer is mainly responsible for indesirable/strange behaviours. Not a great improvement...

At least i worked a lot on it, and cleaned a lot of things and started a better file configuration, and added simultaneous right/front weight transfer. Lateral weight transfer helped a lot in some situations.

[quote name='bmarci' timestamp='1347959888' post='4981185']
Yes, I made a speed sensitive steering which seems to work fine until some heavy intervention is needed, so if my car starts to skid my steering doesn't let me to counteract because of the high speed, and there is only 2-3° of max steering available.
[/quote]
I have kind of the same issue. Maybe simply allow counter steering to go as far as player wants ? I was thinking of something more controled in case of counter-stering / drifting. Like preventing the player from spinning voluntary while cornering.

[quote name='bmarci' timestamp='1347959888' post='4981185']
I use lateral pacejka. The mentioned uncontrollable situation occurs without my special addition.
Earlier I added an extra Vel_long-=wheel_roll_vel; to the contact patch velocity calculation (only for slip angle) since the wheel rolling also affects the contact patch's velocity.
So with that little extra the car is very stable at least on a straight move with lane changes. Maybe it's an "arcadish" tweak for better handling, but without it I have hard time having the car move on a straight line after a little direction change (A simple overtaking is a great challenge, the car is moving off the road and it's a pain in the ...... -somewhere- to put it back on the road again.)
[/quote]
I don't really understand your arcade tweak. But if the car don't want to go straight after a turn, you can try to remove the front/rear weight distribution or tweak a little side weight repartition. I have this issue sometimes because of strange weight balance.

[quote name='bmarci' timestamp='1347959888' post='4981185']
I made a quick force calculations on lateral traction vs. weight transfer; (and noticed some weird result values, see later)

No weight transfer: (steer angle=1°)
Fz_left=3kN
Fy_left=937N
Fz_right=3kN
Fy_right=937N

That's 1874N total lateral force on the front wheels.

With weight transfer, same steer angle (75%R 25%L)
Fz_left=1.5kN
Fy_left=970N
Fz_right=4.5kN
Fy_right=745N

That's 1715N total lateral force which would mean the lateral weight transfer is bad to the stability???
Also my pacejka curve looks good when I display it, but in the last values more load generates less lateral force? I don't get it. Is that normal?
Could you check it with your formula?[/quote]
I don't directly use the pacejka formula, instead i plot a curve with values. The curve i currently use is the one KJM gave above. So back to your question. Yes you have less response force in the end of the curve, despite maybe higher load.

You can consider pacejka curve and weight influence separatly. You can simply give 1N to your formula, get an output and finally multiply by the weight. So with less weight you can get higher forces if the slip angle is ideal. But ! for 90° slip angle for example, you should always get more force as you add more weight if the slip angle is still 90°. Unless i missed something.

The lateral weight repartition is a good thing if there is not too much and enough. If i have only lateral weight transfer without front/rear, it improves greatly stability, but i am not able to start drifts or to corner faster with controled oversteer. Unless my car naturally produce this oversteer.

[quote name='bmarci' timestamp='1347965920' post='4981197']
The error in my theory is probably somewhere at the two wheels don't have the same slip angle at steering[/quote]
You mean the two front wheels ? Mine have almost the same slip angle, but it cas vary a little depending on angular velocity for example. Not sure about what you mean ^^

[quote name='bmarci' timestamp='1347965920' post='4981197']
I just got an idea:

Maybe it's time we started using the aligning moment (Mz) from our favourite Pacejka formula [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I'll try to integrate it into the simulation, so if everything works as I expect the wheels should go back to 0° when I let loose the steering wheel (when moving).
And maybe use steering torques as the drivers hangs on the steering wheel [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] and thus at the peak moment the steering and aligning forces should cancel each outher out.

Does it have any sense or absolutely pointless?

I added mouse steering, so any steer angle can be produced instantly. Very unconfortable, but the skidding is much more controllable.
[/quote]
It is intereseting idea, as i understand it this value can be used to produce response forces in racing driving accessories. Maybe you can use it, but i really dont know if it will improve car handling or drift situations/controling. Not a clue, but my guess would be to improve steer control first or to continue experimenting with your mouse until you can do some nice controled drifts.

[quote name='bmarci' timestamp='1347978787' post='4981265']
An other note about stability. Since my car has 60% load on the rear axle, I played with the pacejka coeffs for the rear wheels so now they produce more lateral traction and thus more stable and eliminated the sudden oversteer, just a bit more grip as you mentioned.
BUT!
Now I cannot skid, not even with handbrake, also donuts work only with nose-weighted cars.
So now I have almost everything but they don't work together. If I reduce grip on the rear tyres I can make the parking-lot-show-off-manouvers but cannot take the first corner on the track. Soon I'm gonna be out of ideas.
[/quote]
We are at the same point my friend. I can have all behaviours separatly, but it is more a car which always have this behaviour than a regular car able to drift, etc. + i really offen have sudden car spins, or car starting to roll backward in a turn easily if i try to drift with a "normal" car. I am not out of ideas, but i am very tired to try things blindly. I think we really need an insight to see which parts of our simulations should be improved to allow for controled drifts with a car which is not naturally oversteering.

Weight transfer is really the thing that seems to have the more influence here. I just integrated front/rear & left/right at the same time, but when i do long turn, at some point the front outside wheel get the highest weight load (while inner rear has the lowest), and then my car spins immediatly.

In fact, all my control loss situations and so do make a lot of sense with regards to physics, the problem is not preveting them but making them fun/controlables. The real problem i almost always have is : when i lose control, instead of starting a controled/credible drift situation, car almost always spins immeditatly, which seems really unrealistic. I feel like i should had some kind of "static lateral" friction which would always be there or something like that i may have missed. I use pacejka forces and nothing else, maybe should i ?

If i have a naturally overseering car, it really feels like i am driving on ice, but i have controled drifts situations.

Also, i always need to multiply my normalized (for 1N) pacejka lateral output. If i get 1100N force for 1000N load @20° slip angle for example, my car is really on ice. I need to multiply by 5-10 to be able to turn at 100-150 kmH. I guess it is not normal right ? The car weight is 1500 kg.

##### Share on other sites
bmarci    786
[quote name='PochyPoch' timestamp='1348702176' post='4984159']
I have kind of the same issue. Maybe simply allow counter steering to go as far as player wants ? I was thinking of something more controled in case of counter-stering / drifting. Like preventing the player from spinning voluntary while cornering.
[/quote]
Yes, this is the point where I need to make more intelligent control. With a steering wheel it would be a piece of cake [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

[quote name='PochyPoch' timestamp='1348702176' post='4984159']
I don't really understand your arcade tweak. But if the car don't want to go straight after a turn, you can try to remove the front/rear weight distribution or tweak a little side weight repartition. I have this issue sometimes because of strange weight balance.
[/quote]
Yes, this is my problam, that neither do I understand it [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Probably it's a bad idea that helps in some situation which should be solved by proper simulation of other (missing) parts (eg: suspension/diffs)

[quote name='PochyPoch' timestamp='1348702176' post='4984159']
I don't directly use the pacejka formula, instead i plot a curve with values. The curve i currently use is the one KJM gave above. So back to your question. Yes you have less response force in the end of the curve, despite maybe higher load.
[/quote]
No, I meant less response force is generated by more load at the same SA/SR. Meanwhile I learnt, that it was correct, and it has a name "load sensitivity" [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
And that is what you lose if you use normalized curve.

[quote name='PochyPoch' timestamp='1348702176' post='4984159']
Weight transfer is really the thing that seems to have the more influence here. I just integrated front/rear & left/right at the same time, but when i do long turn, at some point the front outside wheel get the highest weight load (while inner rear has the lowest), and then my car spins immediatly.
[/quote]
I also calculated with instant weight transfer which shouldn't happen instantly. If I had proper suspension I'd have more transient transfer, and I'm not sure that all "dynamic" weight should be moved because of suspension and anti-roll-bars.

[quote name='PochyPoch' timestamp='1348702176' post='4984159']
In fact, all my control loss situations and so do make a lot of sense with regards to physics, the problem is not preveting them but making them fun/controlables. The real problem i almost always have is : when i lose control, instead of starting a controled/credible drift situation, car almost always spins immeditatly, which seems really unrealistic. I feel like i should had some kind of "static lateral" friction which would always be there or something like that i may have missed. I use pacejka forces and nothing else, maybe should i ?
[/quote]
I don't think you should add static lateral friction, that should come from the tyre model. At least I would like to avoid all possible magic numbers here and there [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
A haven't tought of speed sensitive downforce that every car generates, yet. And the differential. Now I have rigid rear axle, and I suppose you have that too [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
I've seen in other sims using wings also for street cars to "emulate" downforce generated by the chasis shape. I don't think that has too much significance, though. More likely some addition to a more realistic car, and not to a spin or not to spin situation that we have. Edited by bmarci