- Home /
Error getting animation info with Animator
Hi.
I have a 2D animation made by animation window.
In animator, i create this:
![alt text][1]
The animation plays good and i have no problem with this.
But in other script in the same scene, i want show the GUI when the animation ends (MoveCastle ends).
The object are this: ![alt text][2]
and my code is:
public Animator anim;
void OnGUI()
{
if (anim.animation.isPlaying) {
print ("SUCCESS!!!");
}
}
And this not works, i recieve this error:
You probably need to add a Animation to the game object "castleMenu". Or your script needs to check if the component is attached before using it. How i can access to the animation to control it? Im not using avatar or 3d bones because i only animate sprites moving it. Im totaly noobie and i need control the animation flow by code to change scene for example.. Thanks! [1]: http://forum.unity3d.com/attachment.php?attachmentid=78561&d=1386951734 [2]: http://forum.unity3d.com/attachment.php?attachmentid=78563&d=1386951961MissingComponentException: There is no 'Animation' attached to the "castleMenu" game object, but a script is trying to access it.
Your answer
Follow this Question
Related Questions
How to get length of animation in Mecanim? 1 Answer
Is it possible to use the previous animation? (not animator) 1 Answer
Issue with mecanim playing an animation using setbool 1 Answer
Getting a list of mecanim states in Animator 9 Answers
How do I set the time of an animation playing in the animator (Mechanum) 5 Answers