Search Unity

How to make 2 animations (same object)

Discussion in 'Animation' started by NelsonPRSousa, Jun 26, 2014.

  1. NelsonPRSousa

    NelsonPRSousa

    Joined:
    Jan 10, 2014
    Posts:
    43
    Hello community,

    I have a prefab with a sprite attached. I want to do something like this:

    - If I click with the left button of the mouse, the sprite rotates to the left;
    - If I click with the right button of the mouse, the sprite rotates to the right.

    My problem isn't how to create the animation. I selected the gameObject and clicked on "add curve" and rotate the sprite. I have now on my project files two animations. What I need to do now?

    My simple script:

    Code (csharp):
    1. void Update()
    2. {
    3. if(Input.GetMouseButton(0))
    4. {
    5. // Play left animation
    6. }
    7. if(Input.GetMouseButton(1))
    8. {
    9. // Play right animation
    10. }
    11. }
    Thank you for your help, wish you a nice day! :)
     
  2. chrisall76

    chrisall76

    Joined:
    May 19, 2012
    Posts:
    667
  3. NelsonPRSousa

    NelsonPRSousa

    Joined:
    Jan 10, 2014
    Posts:
    43
    Okay it worked. But I lied on the first post. I thought I already have the 2 animations, but actually I just have one, where the sprite rotates to right.

    How can I make another animation, so the sprite can rotate to the left? Because I select my gameObject, I go to Animation view (Ctrl+6), but I can't add a new curve for rotation. :/
     
  4. NelsonPRSousa

    NelsonPRSousa

    Joined:
    Jan 10, 2014
    Posts:
    43
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Select your GO and in the animation window, in the top left corner you should see a drop down with the currently edited animation clip. Click on this drow down and you should have an option to create a new clip. Then you will be able to create a rotation curve for this new clip.
     
    NelsonPRSousa likes this.
  6. NelsonPRSousa

    NelsonPRSousa

    Joined:
    Jan 10, 2014
    Posts:
    43
    Ty good sir!