Having a brain fart here. So, if I have a min and max value, and I want to use a 0 - 1 float range for 0%-100%. How can I make it so that when I input 50%, I will get right in the middle of the min and max?
Something like that?:
//C#
float Map(float min, float max, float t)
{
return min + t*(max-min);
}
Which is basically what Mathf.Lerp does ^^. âtâ should be in range [0-1]
and the returned value is in range [min - max]
.
Example:
float r = Map(3f, 15f, 0.5f); // --> 9
float r = Mathf.Lerp(3f, 15f, 0.5f); // --> 9