'Animation Clip is not playing after mouse click
I have a gameObject with attached animation component, and have added animationClip1.anim with it.
I have the following code
public AnimationClip anim;
void Update () {
if (Input.GetButtonUp("Fire1"))
{
GetComponent<Animation>().Play(anim.name);
}
}
from interface, i have drag and dropped animationClip1.anim to the (above public variable) of the script..
Script is attached to the object.
So when i run the game, i get this error
The animation state 'animationClip1.anim' could not be played because it couldn't be found! Please attach an animation clip with the name 'animationClip1.anim' or call this function only for existing animations.
Where is the problem, why on mouse click i am getting this error.. Any Idea please ? Thanks
Solution 1:[1]
You can try this out
void Update () {
if (Input.GetButtonUp(0))
{
GetComponent<Animation>().Play("Animation name");
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Omdevsinh Gohil |
