6
\$\begingroup\$

I am working on a car-racing game on Unity 2018.1. My car works perfectly at low speed but as it speeds up, I lose control over the car and it starts to drift independently. What can I do to prevent this?

\$\endgroup\$
  • 2
    \$\begingroup\$ For me this sounds like the friction coefficient between car and ground is too low. \$\endgroup\$ – Linaith Jul 2 '18 at 12:02
  • 13
    \$\begingroup\$ Tell us more about how you're controlling your car now, and how its physics are set up. \$\endgroup\$ – DMGregory Jul 2 '18 at 12:47
14
\$\begingroup\$

I think it can be acheived using different ways :

  • Increase the friction on your PhysicsMaterials as Linaith pointed out. It is worth noting that you should have one PhysicsMaterials for your road and one for your tires, and play with the "Friction Combine" parameter ;
  • Increase the "drag" and/or "angular drag" value on your rigidbody component ;
  • Use a compensation force as explained at 4:50 in this video. The goal is very simple : apply a force to the opposide side of the side you are drifting (slightly smaller to allow a bit of drifting though).

I personnaly went for the last one which gives me more control over the car as I am going for a more arcade gameplay. I believe that the other two are more suited for simulation gameplay.

\$\endgroup\$
  • 1
    \$\begingroup\$ I would also suggest looking at this GDC talk from the makers of rocket league. They discuss how they handled their car physics from high speed tight turns, to preventing flipping much more. \$\endgroup\$ – Erudaki Jul 2 '18 at 19:53
  • \$\begingroup\$ @Erudaki Are you sure you linked to the right timecode? It starts with a long pause for applause and then continues with a question about the netcode. \$\endgroup\$ – Philipp Jul 2 '18 at 20:20
  • \$\begingroup\$ I did not link a specific time code. It has been a while since I saw the video, but the majority of the talk is about the physics underlying it and how they tuned it and manipulated the physics to make it feel right. I presumed most of the video is worthwhile to the OP as most the cars in rocket league are moving at high speed, and it required tuning to friction, gravity forces, and applied forces during specific movements or moments to get them to control well at those speeds. \$\endgroup\$ – Erudaki Jul 5 '18 at 18:09

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.