Good implementation. But the car moves back and forth with respect to the global coordinate system. If you use the AddForce method to move forward, try replacing it with AddRelativeForce ;)
The games I did as going through Unity's Create with Code online Tutorials · By
Good implementation. But the car moves back and forth with respect to the global coordinate system. If you use the AddForce method to move forward, try replacing it with AddRelativeForce ;)
I just set the high "Horse Power" (25000). For this course, this is an acceptable solution. I was interested in this question and I found a good video demonstrating the implementation of the car.
As a quick fix, I used WheelCollider.motorTorque:
// Remove force from the car // playerRb.AddRelativeForce(Vector3.forward * horsePower * forwardInput); // Add motor torque to the wheels foreach (var wheel in wheels) { wheel.motorTorque = horsePower * forwardInput; }
This gives a more correct behavior to the car.
Sorry for my English, I use Google Translate :)
Great job man! I was not in the mood then to look for other solutions, but this is great. And it makes so much sense... if you use Wheel Colliders to add torque to the wheels instead of Force to the car.
Kudos to you for this! Thank you!
I added your suggestion and reference to the YouTube video and my original comment on the Unity course
You deserve the reference.