How would you implement a car drifting arcade game mechanic?

Hello,

For personal exercise I’m trying to replicate the control mechanic of the “Hot Slide” mobile game:

My idea was that the car oriented its forward according to the position that the player chooses with his virtual joypad. Car goes straight on in this direction.

The problem arises when I try to imagine how the “drifting” effect could be implemented when the forward of the car suddenly changes.
The car skids with the rear axle and has some inertia.
I assume it can be solved with a fairly basic vector math but that I can’t set up.

Please can anyone help me?

Thank you
Fred

6741043--776845--upload_2021-1-19_19-3-0.png

Just a hint: there’s at least one arcade car controller with sliding mechanics on the asset store that’s free. I believe it implements one of the popular concepts, there are also tutorials about these arcade drift mechanics and how to implement them.

1 Like

I think that’s a rather unusual control for a racing game. Because car cannot go straight to a direction. It can go forward and backward and steer. Normal control for a car even in 2d is “steer”, “accelerate”, “brake”. And those handle drifting just fine.

So with your chosen scheme, when user presses a direction, your car will have to decide how to control steering wheel in order start moving in direction the player wants. And that can make the game quite difficult.

Now, you CAN implement drifting in this control scheme, basically use the same thing as when you’re using “steer, accelerate brake scheme”. When force pushing the car sideways becomes too high, the excessive force will cause it to accelerate and that will cause steering.

Thank you for your kind reply.
I haven’t actually found any serious tutorials on how to implement a drift mechanic in unity.
If you have links can you share them? Thank you

8676540--1169463--upload_2022-12-20_18-15-38.png
8676540--1169463--upload_2022-12-20_18-15-38.png

Well, “inertia” is the tendency for a body to remain in its current state. For the purposes of a driving game, that means that in the absence of external forces it will continue moving in the direction it is currently moving in.

“Drifting” is when the car is moving in one direction while pointing in another.

So essentially what you want is for the car to rotate more quickly than its inertia changes direction. It’s arcadey, so you don’t need to worry about accurate physics for the rotation, so I’d just start by giving my “cars” (they would not be implemented like real cars at all) both a high inertia and a high rotation speed, and just smoothly rotating them towards the input direction.

I know that the objects in that video look like cars, but they behave like Mario running over ice. Don’t try to simulate cars and/or racing controls here, it’s a red herring.

The “drift” part is a combination of tuning your vehicle / character controller, and using a vector dot product to compare an object’s forward direction to it’s velocity.

Actually you can probably do that and it will even feel right.

A wheel is a directional constraint that can cancel specific amount of force directed perpendicular to the wheel. The thing is, amount of force is limited by traction.
Now, when car turns, centrifugal force is applied (if you want to keep it simple), or torque is applied (if you don’t want to).

So you can calculate the moment when the the force surpasses wheel’s ability to cancel it, that’s when the car begins to drift.

Aye, but that’s far more complicated than what’s on show in the reference video.

It’s awesome that you’re working on replicating the drifting mechanic from “Hot Slide” for your own arcade game. Implementing drifting in your game can definitely be achieved with some vector math magic.

To create the drifting effect, you’ll need to handle the car’s orientation and movement in a way that simulates the skidding and inertia. One approach is to calculate the car’s velocity vector based on the chosen direction from the virtual joypad, and then introduce a separate drift vector that influences the car’s movement during the skid. This way, the car’s forward direction can smoothly change while still maintaining some inertia and sliding action.

Remember, it might take a bit of trial and error to fine-tune the mechanic and get it feeling just right, but don’t be discouraged! Keep experimenting, and with a bit of persistence, you’ll nail that awesome drifting feeling.

This sounds a lot like ChatGPT text…

5 Likes