Hi Guys,
I was using Vector3.Lerp to create a load of actions in a coroutine. I now need to make this have an ‘ease in’ ‘ease out’ effect. I found that Vector3.Slerp was likely to do that, however I’m seeing no change in effects. Can anyone explain?
Here’s my code:
for(int i=0; i < endPos.Length; i++)
{
incrPosition = obj.transform.position;
for (float t = 0; t < _duration; t += Time.deltaTime)
{
float dt = t / _duration;
obj.transform.position = Vector3.Slerp(incrPosition, endPos[i].transform.position, dt);
yield return new WaitForFixedUpdate();
}
incrPosition = endPos[i].transform.position;
// Scale
Vector3 origScale = obj.transform.localScale;
Vector3 smallerScale = (origScale * 0.5f);
for (float t = 0; t < 0.25f; t += Time.deltaTime)
{
float dt = t / _duration;
obj.transform.localScale = Vector3.Slerp(obj.transform.localScale, smallerScale, dt);
yield return new WaitForFixedUpdate();
}
for (float t = 0; t < 0.25f; t += Time.deltaTime)
{
float dt = t / _duration;
obj.transform.localScale = Vector3.Slerp(obj.transform.localScale, origScale, dt);
yield return new WaitForFixedUpdate();
}
yield return new WaitForSeconds(_moveInterlude);
}
After googling it says that Slerp is something about directions and circles as opposed to two points in space. I’m not quite sure HOW to use that to make a ‘ease in’ ‘ease out’ effect. Can someone clue me in?
Thanks!