I try to make a gameobject able to play animations stored in a list
I have this error when i try to play an animation :
Default clip could not be found in attached animations list.
UnityEngine.Animation:play ()
This is my code :
public class Animation_ : MonoBehaviour
{
private Animation animComponent;
public AnimationClip animation1;
public AnimationClip animation2;
private void Awake()
{
animComponent = GetComponent<Animation>();
animComponent.clip = animation1;
animComponent.clip.legacy = true;
animComponent.Play();
}
}
The animation i try to play is marked as legacy (set in debug mode).
This error diseapear when i change my code :
public class Animation_ : MonoBehaviour
{
private Animation animComponent;
public AnimationClip animation1;
public AnimationClip animation2;
private void Awake()
{
animComponent = GetComponent<Animation>();
animComponent.clip = animation1;
animComponent.clip.legacy = true;
animComponent.AddClip(animation1,"animation test");
animComponent.Play("animation test");
}
}
But with this code nothing happen(no error, no animation, nothing)
I added a screenshoot of the gameobject and the legacy set in debug mode
Can you help me?
You need to create the “Legacy Animation”
Attach the empty Animation component first and hit Ctr+6 (Will popup the ANimaiton Window)
Then press the the record button and animate like you want, and it will work.
if you have created a Non-legacy animation in the beginning, selecting Legacy bool won’t work.
If you have done as I say and still not working then attach a minimal project with animation and script, will investigate.
Yes i did this however my problem is that nothing is displayed.
I achieve to set the animation in animation component without “Default clip could not be found in attached animations list”
But nothing is displayed.