I am struggling to implement the longitudinal forces for my tyre model in unity. Lateral forces are fine, as it only behaves like a friction, opposing any motion or forces at the contact point. I can turn lateral friction up to basically whatever i like and it remains stable.
The tyre obviously rolls in the longitudinal direction, so it isnt as simple as just opposing the motion or forces. If I just do the same as I with the lateral force, then the tyre doesnt behave realistically (ill get more onto this later).
The only rigidbody is the vehicle, the wheels are just sphere casts shot down from the suspension. The wheels do technically have a ‘mass’ but this is just used for the rotational inertia calculation.
The way that I do the lateral force is, first I calculate the friction that is available to use based on slip angle etc, then I find the amount of slip in the lateral direction in m/s. I then use the dynamic mass of the vehicle at the contact point in the lateral direction and multiply it by the “tractive potential factor” which is basically the magnitude of the vector2 i mentioned earlier that is the maximum potential friction that can be generated, divided by the total potential friction for all of the wheels on the vehicle. I also have a method that takes on a force, torque, a point in world space and the world space centre of mass of a rigidbody. It then returns a vector3 representing the amount of force being applied to that point. I use this to calculate the maximum static friction that can be applied. This is getting a bit long now, but basically this means i can turn up the lateral friction as much as i want (literally to infinity) and it will remain stable, even as low as 30hz and it works great.
If i do the above with longitudinal friction, just swapping lateral slip for longitudinal slip, contact right for contact forward etc, the tyre does not behave correctly. If the tyre is spinning already when it hits the ground and has some slip, all of that force goes into accelerating the car instead of slowing the tyre to meet the road speed. I kind of fixed this by calculating the total effective mass at the contact point by summing the dynamic mass of the vehicle, and the effective mass of the wheel, and then splitting the force appropriately. This means that when no torque is applied to the wheel, the tyre rolls perfectly along the ground, however if torque is applied, the wheel just slips.
If I dont do that correction, the car will accelerate far too rapidly for the given amount of torque. Even just 500nm of torque at the wheel causes it to shoot off, 0 to 120 in 2 seconds. I know that force is torque / radius, which this isnt taking into account, but im not sure how to fully calculate these forces as it becomes very complicated.
Any help is appreciated, thanks. Im aware this is a pretty complex topic, and is less to do with unity itself and more to do with general tyre dynamics. Thanks.