Ok. I will be brief. May be unity have function what i need. I have one variable (call it A) and 2 values, something like 0 and 2000. I need function which return 0 if A == 0, return 1 when A == 2000, and return 0.5 when A == 1000. Something like mathf.lerp, but reverse direction.
As Anders said, divide. In your case because your min is 0, you can just divide by 2000. If your min was something else, it's still division, just with the min removed: Code (csharp): float PercentageOfMinMax(float value, float min, float max) { return (value - min) / (max - min); }
Come to think about it, I did a map range feature for one of my open source tools. https://github.com/AndersMalmgren/F...ne/Globals/ScriptHelpers/FilterHelper.cs#L111 Might give some ideas
Also there's nice function Mathf.Clamp01 wich will help you in case A accidentally will become less than zero or more that 2000.