Search Unity

Synchronizing animations in Unity (solution architecture)

Discussion in 'Animation' started by alexandergikalo, May 13, 2021.

  1. alexandergikalo

    alexandergikalo

    Joined:
    Oct 24, 2019
    Posts:
    19
    Let's implement the classic scheme from 3 in a row: the object has disappeared - all objects that are above are shifted one row below.
    Problem: if you run animations for each of the top objects separately, there is a noticeable desynchronization of motion. + There is a need to catch an event when all fall animations have finished (to perform the following actions / animations and stuff like that). How to properly architect the solution to achieve all of these goals?
    An implementation like this occurs to me:
    • The class that controls the position of objects goes through the list of objects that need to move, assigns them a new position and changes their state to "in motion".
    • When the state changes, each object makes an entry in the "scheduled animations" list.
    • When all objects have been processed, the class raises the "Time to Move" event.
    • The animation player class executes all scheduled nudge animations (synchronizing the time with the first one in the list, if necessary) and upon completion of all creates a nudge completed event.
    The solution looks a little cumbersome, but it should fix the problem. In addition, it will allow you to control the rest of the animations (for example, an explosion that destroys the entire row). Can you please tell me how experienced Unity developers solve this problem?