What's a good way to create a detection meter?

Hi everyone, im making a script for my ai enemy and I made a cone for his line of sight and now im making a detection meter. The detection meter needs to grow faster if the player is : closer to the enemy, is sprinting, and his not in cover. Right now im trying to find a way to make the distance multiplier (if the player is at a max distance return 0.01, if hes at the min distance return 1). I think it has something to do with Mathf.Clamp but I’ve got no idea how to create the script. Does anyone have suggestions?

The following should give you accurate values:

if (distance >= max)
    value = 0.01f;
else if (distance <= min)
    value = 1;
else
    value = (max - distance) / (max - min);

It first of all calculates the extreme cases (beyond max and min). Then it scales the distance as a ratio between the two limits.