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;
  • \$\begingroup\$ Can you show us your code so we can see where the opportunities to introduce this might be, without requiring too much of an overhaul of what you already have? \$\endgroup\$ – DMGregory Jun 8 '20 at 2:17
  • \$\begingroup\$ Thanks, added some sample code. It is very simple. \$\endgroup\$ – Simian Jun 8 '20 at 6:31
  • \$\begingroup\$ Do you need a 100% accurate simulation of physics in your game? If not, you could implement something like a traction variable that determines how much of the steering input is applied to the velocity of the car and how much of it is applied to the rotation of the car itself. \$\endgroup\$ – Agent Tatsu Jun 13 '20 at 19:22
  • \$\begingroup\$ Thanks. I am more interested in supporting a power slide when the player brakes. \$\endgroup\$ – Simian Jun 14 '20 at 1:22
  • \$\begingroup\$ A "power slide" is when the car rotates without changing velocity, also commonly referred to as "drifting"...right? \$\endgroup\$ – Agent Tatsu Jun 14 '20 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.