#StackBounty: #unity #physics #vehicle Custom steering system in Unity for braking and sliding

Bounty: 50

I am developing a game where the player controls a vehicle. But instead of using a first person view, the camera is top-down and orthographic.

I tried using Unity’s wheel collider system. While that would work just fine for a first-person view (e.g. a traditional racing game), the controls don’t work well with a top-down view (e.g. think Micromachines on the NES). The reason, I think, is that turning and acceleration need to be much more responsive with a top-down view than with a real vehicle steering simulation. You’re not racing on a track. When viewing from top-down, the vehicle needs to accelerate and turn much more quickly than a “real” vehicle ever could.

I have implemented my own steering system based on Ackermann steering, which works fine. What I am missing is a good simulation of friction and skidding. For instance, I would like my vehicle to skid and slide if the user brakes while turning.

I don’t have a background in physics or mechanics so I am not sure where to start. Can someone give me some pointers?

Here is the code I have so far for simple steering:

void Move() {
    bool isLeft = Input.GetKey (KeyCode.A);
    bool isRight = Input.GetKey (KeyCode.D);
    bool isUp = Input.GetKey (KeyCode.W);
    bool isDown = Input.GetKey (KeyCode.S);

    turn = 0;

    acceleration = 0;
    speed *= friction;

    if (isReverse != isDown && (isUp || isDown)) {
        speed *= reverseDamping;

    turn += isLeft ? (int) (-angleVel * speed) : 0;
    turn += isRight ? (int) (angleVel * speed) : 0;

    acceleration += isUp ? Time.deltaTime : 0;
    acceleration += isDown ? -Time.deltaTime : 0;
    speed += acceleration;

    transform.Rotate (0, turn, 0);
    transform.Translate (Vector3.forward * speed, Space.Self);

    isReverse = isDown;

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.