- Home /
How do I play an animation from another object C#
Hello, so I have a method which has an object as parameter. Now the question is, I don't seem to find a way to start the animation of that object. this is what I have so far:
public void OpenMenu(GameObject menu){
menu.GetComponent<Animation> ().Play ();
}
I don't get errors but it states that it can't find a default clip in attached animation list. I hope you understand my problem and could help me, thanks in advance.
Comment
Is your animation clip marked as legacy?, check this http://answers.unity3d.com/questions/828207/problems-with-animation-4.html
Answer by shopguy · Apr 15, 2015 at 01:48 AM
What spiceboy said in the comment, and also make sure you have a "default" animation set, or if you want to try playing it by name, use this syntax:
menu.GetComponent ().Play ("AnimationNameGoesHere");