Search Unity

Need help controlling animations of multiple objects

Discussion in 'Animation' started by SwingNinja, Jun 20, 2019.

  1. SwingNinja

    SwingNinja

    Joined:
    Mar 13, 2017
    Posts:
    17
    I'm trying to create multiple objects animation in scene. It's all in 2D and they're not interacting with each other (i.e. A bumps into B). Supposedly I have completely separate objects A, B, C (i.e, Tree, ball, car, etc). Each has about 1 second clip of animation. I want B to start its animation after A is finished its. They don't interact with each other. What I have so far:
    1. Gameobjects A, B, and C
    2. Animation clips for A, B, and C
    3. Animator for A, B, and C attached to the game objects. Each has 1 boolean parameter (i.e. isEnteringTheScreen)
    4. Csharp scripts for A,B, and C attached to the game objects. But basically now just to control the boolean from the Animators.
      1. Example:
        Code (CSharp):
        1. if (Input.GetKeyUp(KeyCode.Space) && anim.GetBool("isEnteringTheScreen") == true) // Start the animation
    5. This starts all the animation right away
    I want to be able to control the animations. For example:
    1. Press spacebar to trigger the animation A.
    2. A enter the screen
    3. B enter the screen after animation A ended
    4. C enter the screen after animation B ended
    5. Press spacebar again, everything starts leaving the screen in reverse order.
    So what is the best way to do this? Thanks.