Game Development Reference
In-Depth Information
28.
float degreesPerSecond = rotationsPerSecond * 360;
29.
30.
//Rotate around local y axis
31.
transform.Rotate(0, degreesPerSecond * Time.deltaTime, 0);
32.
33.
//Steering axis exists in front wheels
34.
if(steeringAxis != null){
35.
//Reset the steering to zero by sbtracting
36.
//the steering value of last frame
37.
transform.RotateAround(
38.
steeringAxis.position,
39.
steeringAxis.up,
40.
-lastSteerAngle);
41.
//Apply new steering value
42.
transform.RotateAround(
43.
steeringAxis.position,
44.
steeringAxis.up,
45.
wheel.steerAngle);
46.
//Update last steering angle value for the next frame
47.
lastSteerAngle = wheel.steerAngle;
48.
}
49.
50.
//Check if the wheel hits the ground
51.
WheelHit hit;
52.
53.
if(wheel.GetGroundHit(out hit)){
54.
//Wheel hits the ground.
55.
//Move the wheel up by spring pressing distance
56.
//Use world space
57.
float colliderCenter = hit.point.y + wheel.radius;
Search WWH ::




Custom Search