Animation Help

Hello, I'm really new to Unity, and I need help with making my animations work in my 2D game. Right now, I want to fix four things:
1. My idle animation draws my base sprite strangely.
2. While turning back and forth, the animation goes back to idle
3. When landing from a jump, the fall animation continues playing before going back to idle
4. The wall hang continues to play while not being on the wall.

The animation part of Unity, and Unity in general is pretty hard for me to grasp. Any help would be apricated.

https://www.youtube.com/watch?v=sH0GNxuq2Mo

Definitely start with the basic Unity tutorials on animation. Nothing anyone types in this little box will be better.

There is the Animator (aka "Mecanim") that uses an Animation Controller and state machines

There is the legacy Animation Component for ultra-simple stuff

Both work with AnimationClips but the clips are not compatible.

When working with Animators (what you have above), g*et the entire state transition setup perfectly* before you write even one line of actual code.

You can test and refine your Animator controller by pressing PLAY and then selecting the object and manipulating the Properties in the Controller to get what you want to happen.

If the state transitions are wrong, all the code in the world won't fix it.

Move slowly, pay attention to all the details. It is a system with a lot of moving parts.

1 Like

Alright thanks, I'll try to do that

It sounds like some of your issues may be related to Transition Duration. On each transition in the animator, there are settings for how long the transition from one state to another should take. This is useful for 3D animations where you want to blend from one animation to another, but I find it very rarely useful in 2D animations.

You can try setting Transition Duration to 0 in the inspector on each of your transitions to see if the animation behavior improves.

9857847--1419864--upload_2024-5-27_10-0-51.png

One other thing you might want to be aware of is the "Can Transition To Self" setting. When you have a transition from "any state" to a state, this option will show up in the inspector. This tells the animator whether to trigger a transition to a state while you are already in this state.

For example, if you have a set of conditions to transition to the "falling" state, and those conditions continue to be true while in that state, then the animator will keep trying to re-start that state. This may not be noticeable if your falling animation is a single sprite, but if your falling animation is multiple sprites, then it may look jittery or only ever show the first frame. In most cases I turn this parameter off for "any state" transitions.
9857847--1419867--upload_2024-5-27_10-4-32.png

I don't know what you mean by "My idle animation draws my base sprite strangely", so I can't help with that.