I’ve been trying to create a min and max value within a min and max value but it doesn’t seem to be working for me the way i would like and I’m kinda stuck with ideas on how to achieve it.
So i have a speed of my game object and when it reaches a speed of 7 the ‘ cookedAmount ‘ will = the min2 value of 0 and when the current speed reaches 10 the ‘ cookedAmount ‘ will then = the max2 value of 3.
currentSpeed = 8.5, cookedAmount = 2. currentSpeed = 9.5, cookedAmount = 2.25 so on…
I’ve tried Mathf.Lerp and Mathf.Clamp and they don’t seem to work properly.
public bool overCooked;
public float cookedAmount;
public float min2 = 0;
public float max2 = 3;
(currentSpeed > 7 && currentSpeed < 10)
{
overCooked = true;
cookedAmount = Mathf.Lerp (min2, max2, currentSpeed / 11.5f);
}
attempt two,
public bool overCooked;
public float cookedAmount;
public float min2 = 0;
public float max2 = 3;
(currentSpeed > 7 && currentSpeed < 10)
{
overCooked = true;
cookedAmount = Mathf.Clamp (currentSpeed * 0.25, min2, max2);
}