- Home /
Animations couldn't be found but still plays
Ok so i have this problems with animations. The animations are done with mocap and imported. They do work and i can get them playing like they should but, and its a big but, i get this error when i play them: "The animation state Block_Mid_01_copy could not be played because it couldn't be found! Please attach an animation clip with the name 'Block_Mid_01_copy' or call this function only for existing animations." I use CrossFade to play the animation and it plays just like they should only i get that error. Now that may not be a big problem but i have another animation i have a event in and it gives me a NullRefernceException when i try to use that animation in a script. But its a bit more strange than that... the function called works when the animation reaches that event but wont work when i call it after that. I have used a script i found here to copy the animation to be able to place events in it. I get the error for ALL imported animations tho, not just the copied one. What im trying to do is in a fighting game i have a block animation. The animation is made in such a way that the model raises its arms and then drops them. What i do with the event is to set the speed of the animation to 0 and then i have a input check for when someone releases that button and set the speed to 1 again. The first part works just as it should (it pauses in block mode) but the second part (where i set the speed to 1 again) refuses to work. Code: Function that is called by the event.
function blockSpeed(speed : float){
if(animation["Block_Mid_01_copy"] == null){
Debug.Log("wtf");
}
animation["Block_Mid_01_copy"].speed = speed;
}
(the first if is actually true and i get a "wtf" in the log... even when the animation speed is set to 0 when the event is reached in the animation) Button up check:
if(Input.GetButtonUp("Block")){
blockSpeed(1);
}
I tried a check to see if the animation is actually existing with a simple check if the animation[x] == null and it IS null... but still playing. Can you play a animation that does not have a clip? Thats the only thing i can think of but it sounds crazy and i have no clue how to solve this problem if that is it.
ok so i switched to c# and it worked... but then i couldnt call a method from the animation event. I finally made that event in code ins$$anonymous$$d of via the animation editor and it worked. If anyone knows how to get the editor thingy to actually call methods in c# i would like to know.
Your answer
Follow this Question
Related Questions
Animation control using Events and .enable 1 Answer
Speed button for animations? 2 Answers
Material transition through animation 3 Answers