When a part or layer moves up and down, or left and right based on a Variable or Datarefs value, the Variable/Dataref value needs to be converted into how many pixels the part or layer should move.
Two things are required:
- The total number of pixels that the layer/part can move.
- The maximum value and sometimes the minimum values that the Variable/Dataref can be.
By dividing the total number of pixels by the maximum value, we have a ratio that can be multiplied with the Variable/Dataref to get accurate movement.
Example: Trim Indicator
The trim indicator above is shown in its initial state and the pointer can move left or right. Its intervals were built using an Interval Spoke Part so we know from the Major Spoke Options it has 11 intervals (Spokes) at 18 pixels apart. There are 5 intervals each side of the centre interval, therefore there are 5 x 18 = 90 pixels left and right of the centre interval to represent the maximum trim indication.
Because the initial state of the pointer is in the middle and not at one of the ends, we only need to consider the 90 pixels in the ratio and not 180 pixels (10 x 18 = 180).
The variable AILERON_TRIM_PCT swings from -100% to 100%. Both maximum/minimum values are the same apart from the sign, which is ideal in this situation as the negative values will cause the pointer to move left and the positive values will move it right.
Therefore our ratio is 90 / 100 = 0.9. So when this is multiplied out, at 100% * 0.9 = 90 pixels to the right and -100% * 0.9 = -90 pixels to the left.
So the Needle layer on the trim indicator would have Data set to AILERON_TRIM_PCT, the Action as MULTIPLY_AS_DECIMAL, the Custom Value as 0.9 and a Gauge Action of MoveX.
If a Variable/Dataref does not go negative, lets say it goes from 0 to 100 with 50 being the centre point, use the SUBTRACT_AND_MULTIPLY_AS_DECIMAL Action to make it go negative. The ratio would be 90 / 50 = 1.8 and the subtraction value would be 50, so when the Variable becomes 49 the result would be 49 - 50 = -1 * 1.8 = -1.8 pixels which would move the pointer to the left.