// if you want to convert a value from one range to another
public float ConvertRange(float value, float range1Min, float range1Max, float range2Min, float range2Max) {
if (range1Min == range1Max) return value;
return ((value - range1Min) * (range2Max - range2Min) / (range1Max - range1Min)) + range2Min;
}