1 using System.Collections;
2 using System.Collections.Generic;
16 protected float pitch = 0f;
17 protected float roll = 0f;
18 protected float yaw = 0f;
19 protected float throttle = 0f;
20 protected float brake = 0f;
21 public int maxFlapIncrements=2;
22 protected int flaps = 0;
24 protected KeyCode cameraKey = KeyCode.C;
25 protected bool camerSwitch =
false;
29 [Header(
"Sticky throttle value control how the throttle can be moved")]
31 protected float throttleSpeed;
32 protected float stickyThrottle;
46 public float Throttle{
52 public float NormalizedFlaps{
54 return (
float)flaps / maxFlapIncrements;
60 public float StickyThrottle {
61 get{
return stickyThrottle;}
63 public bool CameraSwitch{
64 get{
return camerSwitch;}
69 #region Builtin Methods
75 throttleSpeed = (float)CommonFunctions.airplanePreset[CommonFunctions.activeAirplane+
"/throttleSpeed"];
76 #
if !UNITY_EDITOR && UNITY_WEBGL
78 WebGLInput.captureAllKeyboardInput =
false;
85 StickyThrottleControl();
93 #region Custom Methods
99 pitch = Input.GetAxis(
"Vertical");
100 roll = Input.GetAxis(
"Horizontal");
101 yaw = Input.GetAxis(
"yaw");
102 throttle = Input.GetAxis(
"throttle");
104 StickyThrottleControl();
106 brake = Input.GetKey(KeyCode.Space)?1f:0f;
109 if(Input.GetKeyDown(KeyCode.F)){
112 if(Input.GetKeyDown(KeyCode.G)){
115 flaps = Mathf.Clamp(flaps, 0,maxFlapIncrements);
118 camerSwitch = Input.GetKeyDown(cameraKey);
122 protected virtual void HandleInputNew(){
130 void StickyThrottleControl(){
131 stickyThrottle = stickyThrottle + (throttle*throttleSpeed*Time.deltaTime);
132 stickyThrottle = Mathf.Clamp01(stickyThrottle);
139 pitch = Mathf.Clamp(pitch,-1f,1f);
140 roll = Mathf.Clamp(roll,-1f,1f);
141 yaw = Mathf.Clamp(yaw,-1f,1f);
142 throttle = Mathf.Clamp(throttle,-1f,1f);
143 brake = Mathf.Clamp(brake,0f,1f);
144 flaps = Mathf.Clamp(flaps, 0, maxFlapIncrements);
154 if(DBInputControlType ==
"Code")