I want to scale a value example:

Value clamp between `27 and 39`

I want to scale it to a `0 and 1 value.`

Any help?

I want to scale a value example:

Value clamp between `27 and 39`

I want to scale it to a `0 and 1 value.`

Any help?

I found the anwser on the web :

```
#pragma strict
var min : float;
var max : float;
var i : float;
var normalizedFloat : float;
function Update(){
//Calculate the normalized float;
normalizedFloat = (i - min) / (max - min);
//Clamp the "i" float between "min" value and "max" value
i = Mathf.Clamp(i, min, max);
//Clamp the normalized float between 0 and 1
normalizedFloat = Mathf.Clamp(normalizedFloat, 0, 1);
}
//Source : http://stn.spotfire.com/spotfire_client_help/norm/norm_scale_between_0_and_1.htm
```

I did this in C#

void PlayerHpLowWarning(float hp)

{

```
if (hp <= 0.35)
{
float min = 0.0f;
float max = 0.35f;
float normalizedFloat;
//Calculate the normalized float;
normalizedFloat = (hp - min) / (max - min);
//Clamp the "nFloat" float between "min" value and "max" value
hp = Mathf.Clamp(hp, min, max);
//Clamp the normalized float between 0 and 1
normalizedFloat = Mathf.Clamp(normalizedFloat, 0, 1);
//Reverse the normalized float so it works with the float
normalizedFloat = -1.0f * (normalizedFloat - 1.0f);
colorHpWarning.a = normalizedFloat;
playerHpWarning.color = colorHpWarning;
}
else
{
colorHpWarning.a = 0.0f;
playerHpWarning.color = colorHpWarning;
}
}
```