Ways to Unity 18: Animation

1. Create Animation Clips

  1. Window -> Animation -> Animator
  2. Select an object, hit the record red button, do some movement for your object

2. Create Animator Controller

  1. go to project window
  2. Right-click -> Create -> Animator Controller -> double click it
  3. Drag and drop all of your animation clips into the popup layer. (after this, you’ll get a lot of colorful blocks)

3. Attach the Animator Controller into your object, and also create a new script for your object 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class move_the_ceiling : MonoBehaviour
{
    Animator anim;

    void Start()
    {
       anim = GetComponent<Animator>(); 
    }

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Keypad0)) {
            anim.Play("animation clip filename 1");
        else if (Input.GetKeyDown(KeyCode.Keypad1)) {
            anim.Play("animation clip filename 2");
        }
    }
}

4. Animation Transition (It’s a little bit complex, not recommend to learn)

https://youtu.be/PNsM9ULD9fk