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)
allaga, 2019-06-22

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

DIEMONIC, 2019-06-30

Personally, I implemented animation in a different way:
public Animator Animator1;
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