- Home /
Legacy animation not playing - no errors?
I am trying to animate my character with the legacy animation system. There are no errors, and the animation clip appears in the 'animation' component, but the animation doesn't play. I have a script to make it play here:
using UnityEngine;
using System.Collections;
public class playerAnimation : MonoBehaviour {
public AnimationClip anim;
void Update (){
if(Input.GetKeyDown(KeyCode.A)){
animation.clip = anim;
animation.Play();
}
}
}
the animation must be made for your model don't, retarget if you are doing it,
make sure your animation in the project view is actually set to "legacy" and not "generic". In the script below it requires you to manually place the animation component and the animation clip in the appropriate slot. Also make sure on animation component you have the animation clip under "Animations"
using UnityEngine;
using System.Collections;
public class playerAnimation : $$anonymous$$onoBehaviour {
public AnimationClip animClip;
public Animation anim;
void Update (){
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A)){
anim.Play(animClip.name);
}
}
}
Answer by sampenguin · Sep 09, 2015 at 01:01 AM
I was having a similar problem, very frustrating. I found that calling a different overload with explicit playmode defined in Animation.Play/CrossFade made it work.
So instead of just anim.Play("name") try using
anim.Play("name", PlayMode.StopAll);
or
anim.CrossFade("name", 0.5f, PlayMode.StopAll);