local MATH = {} function round(x) return x + 0.5 - (x + 0.5) % 1 end function MATH:Normalize(x, A, B, C, D) -- (A, B) - The minimum and maximum values in the current range. (C, D) - The minimum and maximum values of the desired range. (x) - The current value in the current range. local Normal = (x - A)*(D - C)/(B - A) return round(Normal/0.01)*0.01 end return MATH
I have a slider that determines the speed and rotation of the camera in game. To read this input I normalize the values to 0, 1 range.
When the GUI's normalized position is at 0.5 the Camera should come to a full stop.
The problem is, in order to center the position of the slider the offset of the slider on the X axis needs to be set to 1/2 of the slider's absolute size.
On the Ipad mini, the GUI's Absolute Size is 77. So to center the slider the slider's offset on the X axis will be 77/2. The problem begins with the fact that offset does not accept anything other than a whole number.
Because of this, the normalized center for the slider on the Ipad mini is 0.48.
I need a way to ensure that the normalized center is always 0.5.
Is this at all possible?
-- This determines the speed and direction of the camera's rotation MATH:Normalize(Slider.Position.X.Offset, 0, Slider.AbsoluteSize.X, 0, 1)
~ Thanks, AZDev