Animation doesn't play

I made a animation and it doesn’t play.
Can someone explain me what is happening? Do i need to show anything?
If yes, please let me know.

Well this could be anything and the lack of information doesn’t help. However, I will do my best to give you some tips of things to look at.

Tip 1:
Make sure your custom animation is the correct type. If using in a mecanim “Animator” component you can’t use “Legacy” animations with it. If you are using “Legacy” animations then you need to use an “Animation” component.

Tip 2:
If your animation is short and doesn’t loop it may be playing but will only play once. So it could be playing then stop so fast that you don’t notice it.

Tip 3:
Make sure your animation is applied to the correct component!

Tip 4:
If you are using a humanoid character make sure that you use a humanoid animation. Sometimes “Generic” animations work but make sure these things match up.

Tip 5:
If making your own animation you need to make sure that what character you make it on is the character that you are going to play it on. I have never had success making animations on one character and playing them on another (this is unless you make it with a program outside of Unity).

Hope these tips help you.

Another thing to check: is the object you are trying to animate marked as static? In the animation preview the animation will play, but it won’t in the game preview (when you press the “Play”-button) or when you actually compile and run.

@wesleywh: thank you so much, Tip 1 saved my day! After trying about ten different suggestions on how to fix my animation problem, just replacing ‘Animator’ with ‘Animation’ Component did the trick for me.

If you are using the “Animation” component make sure you feed the animation clip to both the “Animation” and “Animations” fields.
Your animation clip should also be marked as “Legacy” you can do it by switching to debug mode in the inspector (press the three dots icon beside the lock icon and select debug) then select the animation clip and change the type to legacy.
Please note that legacy animation clips will not be played in the “Animator” component.

If I understand correctly, you have created an animation, and now you need to play it? if so, you need to run your animation in the animator (Window->animator). You use this to play an animation, loop it, run it based on parameters in a script, and so on.

Here is a link on how to use the Animator:

Attach an script to the GameObject with the animation, something like this:

using UnityEngine;
using System.Collections;
  
public class playAnimationScript : MonoBehaviour
{
    Animation yourAnimation;
  
    void Awake()
    {
        yourAnimation = yourGameObject.GetComponent<Animation>();
    }
  
    // This is an example only  
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            yourAnimation.Play("yourAnimationName");
        }
    }
}

i had the same issue, just changed the Update Mode to Unscaled Time and its working perfectly.

Go to ANIMATOR component → right click → click on OPTIMIZE TRANSFORM HIERARCHY.
I don’t know how it works but it works!

my animation does not work it works perfectly fine in the “animation” but in the game it does not work