- Home /
Animation doesn't play
I don't even know what to write. Basically, 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.
Answer by FabriBertani · Aug 13, 2016 at 11:05 PM
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");
}
}
}
Answer by wesleywh · Aug 13, 2016 at 10:27 PM
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.
Answer by itr-prototype · Mar 13, 2017 at 04:26 PM
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.
Answer by BetaAnalysis · Aug 14, 2016 at 01:20 AM
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 https://www.youtube.com/watch?v=wdOk5QXYC6Y
Your answer
Follow this Question
Related Questions
GUITexture touch play animation 0 Answers
Proper way to play non looping animations 2 Answers
Attack Animation problem 1 Answer
How to get an object move by itself 2 2 Answers
Ped models do not want to play one animation at the same time 1 Answer