Game Development Reference
In-Depth Information
96.
UpdateSteering(0);
97.
}
98.
99.
//Update brakes
100.
if(brake){
101.
foreach(WheelCollider wheel in frontWheels){
102.
wheel.brakeTorque = brakesTorque;
103.
}
104.
105.
foreach(WheelCollider wheel in backWheels){
106.
wheel.brakeTorque = brakesTorque;
107.
}
108.
brake = false;
109.
} else {
110.
foreach(WheelCollider wheel in frontWheels){
111.
wheel.brakeTorque = 0;
112.
}
113.
114.
foreach(WheelCollider wheel in backWheels){
115.
wheel.brakeTorque = 0;
116.
}
117.
}
118.
}
119.
Listing 42: Start() and FixedUpdate() functions of PhysicsCarDriver script
In Start() function, we first convert maxSpeed and maxReverseSpeed from km/h to RPM.
The conversion is performed by KmphToRPM() function, which we are going to discuss in
details shortly. The converted values are stored in maxRPM and maxReverseRPM variables.
Search WWH ::




Custom Search