#staggering animations

1 messages · Page 1 of 1 (latest)

steel fractal
#

    public void ShowCards()
    {
        for (int i = 0; i < cards.Length; i++)
        {
            cards[i].GetComponent<Animator>().SetTrigger("slide in");
            Wait(0.3f);
        }
    }

    IEnumerator Wait(float time)
    {
        yield return new WaitForSeconds(time);
    }```

i have an array of objects who all have the same animation, which i want to play at separate times one after another (0.3 seconds delay between the last one). when i run this though, all of them are animated at the same time. what am i doing wrong?
white brook
#

waitforseconds is only waiting inside the Wait

#

you would want to do your settrigger thing in a coroutine

#

eg.

IEnumerator SomethingName()
for (length)
setrigger
waitforseconds(time);

steel fractal
#

ahh okay. well that kinda sucks a bit cause i wanted to reuse the wait coroutine for other things but if thats how itll work, i will try that

#

thank you