I would like to increase the value of a float over time but with added In-Out easing.
Here I'm using Mathf.Lerp and I know there is Mathf.Smoothstep but in SmoothStep, I can't seem to control the speed of the easing itself. I would like the easing to start from a certain value to another value over a specific time(range?) I choose. For example, if the float is changing from 0 to 100, I would like the easing to be from 0 to 20 and again from 70 to 100.
Here is the current code I'm using:
float minValue = 0;
float maxValue = 100;
float duration = 10;
float value;
void Start()
{
StartCoroutine(IncreaseSpeed(minValue, maxValue, duration));
}
private IEnumerator IncreaseSpeed(float start, float end, float duration)
{
float time = 0;
while (time <= duration)
{
time = time + Time.deltaTime;
value = Mathf.Lerp(start, end, time / duration);
yield return null;
}
}
Maybe something like this?