Hi all,
I’m just experimenting with LeanTween.
What I don’t get is how do you execute a couple of consecutive tweens on a GameObject?
Like, first scale it, then when it finishes do moveY, then as it completes, do some rotation… etc.
I found a chain(?) method setOnComplete if it is used for this purpose but I’m not sure if I’m doing it correctly.
Basically how do you tell if a tween is completed and order the script to execute another upon completion?
At the moment I’m doing something like below…
This seems to work fine but I’m not sure if this is performant or should be done this way.
private void Start()
{
StartCoroutine(MyObjectAnimation());
}
IEnumerator MyObjectAnimation()
{
LeanTween.moveY(gameObject, gameObject.transform.position.y + 2f, 1f).setEaseInOutSine().setIgnoreTimeScale(true);
yield return new WaitForSeconds(1f);
LeanTween.moveY(gameObject, gameObject.transform.position.y - 2f, 1f).setEaseInOutSine().setIgnoreTimeScale(true).setOnComplete(RepeatAgain);
yield break;
}
void RepeatAgain()
{
StartCoroutine(MyObjectAnimation());
}
Thank you!