F
F
FloweRWolF2021-05-25 16:42:18
Unity
FloweRWolF, 2021-05-25 16:42:18

How to get current character animation?

void Update()
    {
        if(Input.GetKey (KeyCode.UpArrow)) {
            anim.SetInteger ("Number", 2);
        } else {
             anim.SetInteger ("Number", 1);
         }   
    }

Reset animation when colliding with an enemy:
if (shit.gameObject.tag == "Enemy1") {
            anim.SetInteger ("Number", 3);
            Invoke("reloadLevel", 1);
        }

I'm trying to create a condition so that animation 1 starts when there is no animation 3, but I don't know how to get the currently running animation.
if(Input.GetKey (KeyCode.UpArrow)) {
            anim.SetInteger ("Number", 2);
        } else if//(anim.GetInteger != 3) {   ???
             anim.SetInteger ("Number", 1);
         }

If there are other ways like animation "1" won't reset animation "3" then I'm all ears. The idea is that after hitting an obstacle, animation 3 (Explosion) starts, and after a second the level restarts, but animation 1 that is still, knocks animation 3.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question