1 using System.Collections;
2 using System.Collections.Generic;
7 {
public enum ControlSurfaceType{
19 [Header(
"Control surface Properties")]
20 public ControlSurfaceType surfacetype = ControlSurfaceType.Rudder;
21 private float maxAngle;
22 public Vector3 axis = Vector3.right;
23 public Transform controlSurfaceGraphic;
25 private float smoothSpeed;
26 private float wantedAngle;
29 #region Builtin Methods
32 maxAngle = (float)CommonFunctions.airplanePreset[CommonFunctions.activeAirplane+
"/maxAngle"];
33 smoothSpeed= (
float)CommonFunctions.airplanePreset[CommonFunctions.activeAirplane+
"/smoothSpeed"];
40 if(controlSurfaceGraphic){
42 Vector3 effectiveRotationAxis = axis*wantedAngle;
43 controlSurfaceGraphic.localRotation = Quaternion.Slerp(controlSurfaceGraphic.localRotation, Quaternion.Euler(effectiveRotationAxis), Time.deltaTime*smoothSpeed);
48 #region Custom Methods
55 float inputValue = 0f;
58 case ControlSurfaceType.Rudder:
59 inputValue = input.Yaw;
61 case ControlSurfaceType.Elevator:
62 inputValue = input.Pitch;
64 case ControlSurfaceType.Flaps:
65 inputValue = input.Flaps;
67 case ControlSurfaceType.Alerons:
68 inputValue = input.Roll;
74 wantedAngle = maxAngle*inputValue;