1 using System.Collections;
2 using System.Collections.Generic;
14 [Header(
"Altimeter Properties")]
15 [Tooltip(
"Drag and drop Airplane Here")]
18 [Tooltip(
"Drag and drop Hundreds pointer Here")]
20 private RectTransform hundredspointer;
21 [Tooltip(
"Drag and drop Thousands Pointer Here")]
23 private RectTransform thousandsPointer;
26 #region Builtin methods
32 #region Interface Methods
40 float currentAltitude = airplane.CurrentMSL;
41 float currentThousands = currentAltitude/1000f;
42 currentThousands = Mathf.Clamp(currentThousands,0,10);
44 float currentHundreds = currentAltitude - (Mathf.Floor(currentThousands)*1000f);
45 currentHundreds = Mathf.Clamp(currentHundreds, 0f,1000f);
50 float radialThousands = Mathf.InverseLerp(0,10,currentThousands);
51 radialThousands = 360f * radialThousands;
52 thousandsPointer.rotation = Quaternion.Euler(0f,0f,-radialThousands);
57 float radialHundreds = Mathf.InverseLerp(0f,1000f,currentHundreds);
58 radialHundreds = 360f * radialHundreds;
59 hundredspointer.rotation = Quaternion.Euler(0f,0f,-radialHundreds);