Hey,
I was wondering what the easiest way to find the function for a graph like this would be:
As you can see, it has a sort of “wobble” at the end where it overshoots 1 and then bounces back. Currently I am using a somewhat messy solution as shown below. I would imagine this curve would have a pretty simple function if I could figure it out
// start and end values
float startSize = 1;
float endSize = 5;
float duration = .75f;
float t = 0f;
float newScale = 0f;
// SmoothStep through each peak/valley
while (t < 1)
{
t += Time.deltaTime / (duration * .5f);
newScale = Mathf.SmoothStep(startSize, endSize * 1.2f, t);
transform.localScale = new Vector3(newScale, newScale, newScale);
yield return null;
}
t = 0f;
while (t < 1)
{
t += Time.deltaTime / (duration * .2f);
newScale = Mathf.SmoothStep(endSize * 1.2f, endSize, t);
transform.localScale = new Vector3(newScale, newScale, newScale);
yield return null;
}
t = 0f;
while (t < 1)
{
t += Time.deltaTime / (duration * .15f);
newScale = Mathf.SmoothStep(endSize, endSize * 1.14f, t);
transform.localScale = new Vector3(newScale, newScale, newScale);
yield return null;
}
t = 0f;
while (t < 1)
{
t += Time.deltaTime / (duration * .15f);
newScale = Mathf.SmoothStep(endSize * 1.14f, endSize, t);
transform.localScale = new Vector3(newScale, newScale, newScale);
yield return null;
}