Search Unity

how to reuse animator

Discussion in '2D' started by ba01, Sep 1, 2014.

  1. ba01

    ba01

    Joined:
    May 8, 2014
    Posts:
    10
    I am new unity.

    I have already watched this tutorial in


    When i do step by step from above tutorial (above link). As a result, I get:
    + two animation: idle status and move status. (animation tab)
    + One animator: take transition to transfer from idle status to move status by press key. (animator tab)

    But i want to add new another character with other color. Surely, i should create two new animation from my sprite.
    How i can reuse above animator, i don't want to create transitions to transfer status again.

    I have a lot of characters with another colors in a scene.They have same status (move left, move right, move up, move down and idle). So i want to reuse animator.

    Please help me, thanks a lot. (If you don't understand, please tell me, i will explain further)
     

    Attached Files:

    • pic.jpg
      pic.jpg
      File size:
      121.6 KB
      Views:
      987
  2. Punchbag

    Punchbag

    Joined:
    Oct 30, 2012
    Posts:
    48
    Hi,

    You can't re-use animators for 2D sprites as far as I know. Your animator looks like it's way more complex than it needs to be though.

    Using arrow brackets for transitions, you only need:

    Move Up <> Move Right <> Move Down <> Move Left

    Where the first transition says direction greater than zero to go right, less than 1 to go back to Up. The second transition says direction greater than 1 to go to the down animation, less than 2 to return back to the right animation.

    Then have a transition from "Any Transition" that jumps to the up idle animation, with the same direction transitions as above.

    Why Will This Work?

    Let's say you're at direction zero, and you're playing the up animation. You move down, setting direction to 2. The animator does this:

    Up transition to Right: Greater than 0? Yes, transition.
    Right transition to Down: Greater than 1? Yes, transition.
    Down transition to Left: Greater than 2? No, stay on Down.

    And the single transition from Any State to idle up when speed is zero and move up when speed is greater than zero means:

    At any time, if speed becomes zero, jump to idle up. If your character direction isn't zero, it will then immediately also go along to the correct direction per the process as described above.
     
  3. velipekka

    velipekka

    Joined:
    Jun 2, 2014
    Posts:
    9
    ba01 likes this.
  4. ba01

    ba01

    Joined:
    May 8, 2014
    Posts:
    10
    Thanks velipekka, it help me so much.