- Home /
Question by
PanCrucian · May 02, 2013 at 05:40 PM ·
mathf
How to get a value between 0 and 1
How to get a value between 0 and 1 that I know the input value, minimum and maximum values; For Example How Do this function: float needValue = GetBetweenValue(min,max,inputValue);
public float GetBetweenValue(float min,float max, float inputValue) {
... return 0.0f or 1.0f depending on how the value is close to the min and max;
}
Comment
Answer by ExTheSea · May 02, 2013 at 05:42 PM
What about using Mathf.Round?
http://docs.unity3d.com/Documentation/ScriptReference/Mathf.Round.html
float needValue = Mathf.Round(inputValue);