S
S
Stanislav Yaroslavtsev2019-06-21 05:25:30
C++ / C#
Stanislav Yaroslavtsev, 2019-06-21 05:25:30

2D character animation not working in Unity. Why?

I'm making a 2D game on Unity 5.6. Faced a problem - the animation does not work. I use Animation and did everything right: installed Legacy, etc. I call the animation in the code like this:

if (Input.GetKeyDown (KeyCode.Space)) {
        GetComponent<Animation>().Play ("my_animation_name");
}

But she doesn't lose. There are no errors in the console. Does anyone have any ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
allaga, 2019-06-22
@allaga

you can try without if (Input.GetKeyDown (KeyCode.Space)) { }

D
DIEMONIC, 2019-06-30
@DIEMONIC

Personally, I implemented animation in a different way:
public Animator Animator1;
Animator1.Play("my_animation_name");
on the animator you hang an object with an installed animator, inside of which your animation already lies

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question