... | ... | @@ -18,6 +18,8 @@ Wheel colliders come with preset options that can be used to help determine the |
|
|
|
|
|
I would create SerializedFields for all the WheelColliders on the car, and bring them into the script. Then I would apply forces to each WheelCollider. These forces would be calculated from the Input of W and S, which are under the Vertical Axis. This gives a number between 1 and -1 which acts as a constant in telling what direction the acceleration should apply to; 1 to accelerate, -1 to reverse. I would then multiply this value by an acceleration constant to get the current acceleration that would be applied to the frontLeft and frontRight wheels motorTorque. MotorTorque essentially adds a force to the car for WheelColliders.
|
|
|
|
|
|

|
|
|
|
|
|
Braking would also be applied depending on whether the LeftControl button was held down. If it was, a braking constant would be applied to all 4 wheel colliders' brakeTorque. BrakeTorque will slow down the car.
|
|
|
|
|
|
I would also then update the actual wheels on the model to match the position of the WheelColliders.
|
... | ... | |