1 using System.Collections;
2 using System.Collections.Generic;
14 public bool isGrounded =
false;
15 public bool IsGrounded
17 get{
return isGrounded; }
22 [Header(
"Wheel Properties")]
23 public Transform wheelGraphic;
24 public bool isBraking=
false;
25 private float brakePower;
26 public bool isSteering=
false;
27 private float steerAngle;
28 public float motorTorque;
30 private WheelCollider wheelCol;
31 private Vector3 worldPos;
32 private Quaternion worldRot;
33 private float slowlyBrake;
36 #region Builtin Methods
40 brakePower = (float)CommonFunctions.airplanePreset[CommonFunctions.activeAirplane+
"/brakePower"];
41 steerAngle = (
float)CommonFunctions.airplanePreset[CommonFunctions.activeAirplane+
"/steerAngle"];
42 wheelCol = GetComponent<WheelCollider>();
51 if (wheelCol.GetGroundHit(out hit) && (StaticOutputSchema.IfCollision ==
false)){
52 string surface = hit.collider.tag;
53 float wheelPenalty = 100.0f;
54 if(hit.collider.tag !=
"Runway"){
55 StaticOutputSchema.Reward -= wheelPenalty;
56 StaticOutputSchema.IfCollision =
true;
57 StaticOutputSchema.CollisionObject = surface;
74 wheelCol.motorTorque = 0.0000000001f;
86 wheelCol.GetWorldPose(out worldPos, out worldRot);
89 wheelGraphic.rotation = worldRot;
90 wheelGraphic.position = worldPos;
94 if(input.Brake > 0.1f)
97 slowlyBrake = Mathf.Lerp(slowlyBrake,input.Brake*brakePower, Time.deltaTime );
98 wheelCol.brakeTorque = slowlyBrake;
100 wheelCol.motorTorque = 0.0f;
106 wheelCol.brakeTorque = 0.0f;
108 wheelCol.motorTorque = motorTorque;
113 wheelCol.steerAngle = -input.Yaw * steerAngle;
117 isGrounded = wheelCol.isGrounded;