Stop Car Sliding Sideways on a slope (+GIF)

Greetings

I have a problem with Unity’s Car Tutorial alternate physics model wheels script.
The issue can be seen in the following gif:

I’ve added the following small script to stop it from slipping :

if(speed == 0)
                suspensionForce = new Vector3(0f,suspensionForce.y,0f);

Although it works , it also prevents it from completely sliding no matter how positioned the car on a slope.
I would like a solution where a car wouldn’t slide sideways on a slope unless the tires are positioned properly.

I can code but I lack in the physics area , I’d go as far to say that I don’t really know what should I really target in the wheels script , could it be the slipping angle or suspension force or some force I don’t know about causing this?

Thank you all for your time.

Do you try play around with WheelCollider Sideways Friction → stiffness values?

The alternate physics model does not use WheelCollider , instead it uses a custom Raycast wheels script , here take a look at it: https://github.com/ZeningQu/CarRacingGame/blob/master/Assets/~AlternatePhysicsModel/Scripts/Wheel.cs

That’s by design. The alternate physics model computes the tire forces based on the slip (= sliding velocity over the ground). It doesn’t implement adherent friction.

Thanks Edy , I assume that means I should rewrite and make my own wheel raycast script with friction curves x_X

No, as Edy’s said, it’s not about friction curves, tire physics is not that simple :wink:

Teach me Sir -

read side velocity and apply counter force. it’s not trivial enough for someone to bother teaching you how to solve what is a complex problem. You probably want to google how to get relative velocity first.

Okay , I will google it , thank you for the kind support. ^-^/

It takes months/years for experienced studios to develop car physics that are more or less SIMILIAR to real car behaviour. So my advice - don’t try to make realistic car behaviour, or buy ready solution from Edy is you really need something that can be called sim. Also no offence, but you shouldn’t call your game sim if you are using “Unity’s Car Tutorial alternate physics”, as it has nothing to do with simulation :wink:

1 Like

You are totally right Roni , actually I’m not really planning to publish anything or the game as it lacks quality, I’m just learning it for fun and for the name its just temporary as I can’t think of anything good but will do change it in the future to avoid the confusion. :slight_smile:

Read tire velocity and apply counter force is a simple solution that works on most situations (Edy’s Vehicle Physics is more or less based on that). But the tricky part is to calculate the adherent forces that are produced even when there’s no effective sliding over the ground (i.e. slow turns without sliding or vehicle steady on slopes). This can be considered a physics challenge itself.