Beispiel #1
0
 public void InitCharacteristics(Rigidbody curRB, BaseAirplane_Input curInput)
 {
     input            = curInput;
     maxMPS           = maxMPH / mpsToMph;
     rb               = curRB;
     startDrag        = rb.drag;
     startAngularDrag = rb.angularDrag;
 }
Beispiel #2
0
        public void HandleWheel(BaseAirplane_Input input, bool handbrake)
        {
            if (WheelCol)
            {
                WheelCol.GetWorldPose(out worldPos, out worldRot);
                if (WheelGraphic)
                {
                    WheelGraphic.rotation = worldRot;
                    WheelGraphic.position = worldPos;
                }

                if (isBraking)
                {
                    if (handbrake)
                    {
                        finalBrakeForce      = Mathf.Lerp(finalBrakeForce, 1f * brakePower, Time.deltaTime);
                        WheelCol.brakeTorque = finalBrakeForce;
                    }
                    else if (input.Brake > 0.1f)
                    {
                        finalBrakeForce      = Mathf.Lerp(finalBrakeForce, input.Brake * brakePower, Time.deltaTime);
                        WheelCol.brakeTorque = finalBrakeForce;
                    }
                    else
                    {
                        finalBrakeForce      = 0f;
                        WheelCol.brakeTorque = 0f;
                        WheelCol.motorTorque = 0.000000001f;
                    }
                }

                if (isSteering)
                {
                    WheelCol.steerAngle = -input.Yaw * steeringAngle;
                }
            }
        }