- Home /
Can't Find Animation
Hello I have this script which is trying to play an animation, but every time I run it I get this error message:
The animation state openDoor2 could not be played because it couldn't be found! Please attach an animation clip with the name 'openDoor2' or call this function only for existing animations. UnityEngine.Animation:Play(String) doorOpen2:Update() (at Assets/doorOpen2.js:17)
The animation is attached to a empty game object which has a cube inside. My previous script worked and it is exactly the same appart from the animations are different, I have checked the names of the animations are correct and they are, the only difference I can find is that the animations themselves.
This one has practically no options in the inspector. (this one works)
Whereas this one has lots more options. (this one cant be found)
This is the script:
var detectionRange : float;
var closeEnough : boolean;
var player : Transform;
var doorOpen : boolean = false;
var doorClip : AnimationClip;
function Update(){
closeEnough = false;
detectionRange = 2;
if ( doorOpen == false){
if( Vector3.Distance( player.position, transform.position) <= detectionRange ){
closeEnough = true;
}
if( closeEnough && Input.GetKeyUp(KeyCode.E)){
Debug.Log("Opening");
GameObject.Find("door").animation.Play("openDoor2");
doorOpen = true;
}
}
}
function OnGUI(){
if( closeEnough){
GUI.Label(Rect(50,50,200,25), "You may press E!!!");
}
}
Thanks
Ryan.
I managed to fix it. I went on to the animation itself and changed the view to debug and changed the animation type to '1' or Legacy (I think).
Your answer
![](https://koobas.hobune.stream/wayback/20220613144544im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can I make animations snap to a frame? 1 Answer
How to select an animation clip by index number? 7 Answers
Urgent please. Can't Find Scene in build settings while scene is in build settings. 0 Answers
Setting up health script. will not work, 1 Answer
Can the animation editor create local rotational data? 3 Answers