Unity UI animation does not played

So I want to make Damage pop up and move it like Diablo3’s damage effects.

So I wrote code like

public GameObject damagePrefab;
    public Transform damageTransform;
    public int tempDam;
    public Canvas mainCanvas;

    void Start() {

    }

    void Update() { 
        if (Input.GetKeyDown("q")) {
            CreateDamagePopup(tempDam);
        }
    }
 
    public void CreateDamagePopup(int damage) {
        GameObject damgo = (GameObject) Instantiate(damagePrefab, damageTransform.position,
            damageTransform.rotation);
        damgo.GetComponentInChildren<Text>().text = damage.ToString();
        damgo.transform.parent = mainCanvas.transform;
        damgo.transform.localPosition = new Vector3(0, 0, 0);
        damgo.GetComponent<Animation>().Play();
    }

But animation does not played after instantiate prefab.

Why?

Try unchecking the Apply Root Motion under the Animator component and try again.

The animation should auto play without the need of this line (because it’s set to Play Automatically):

damgo.GetComponent<Animation>().Play();

Thanks! So ‘Apply Root motion’ is bad guy!