.GetButton issue

Im having an issue with the the script:

if(Input.GetButton(“Run”))
{
animation.CrossFade(“run”);
walkSpeed = 4;
}

This is the error i get:

The animation state run could not be played because it couldn’t be found!
Please attach an animation clip with the name ‘run’ or call this function only for existing animations.
UnityEngine.Animation:CrossFade(String, Single, PlayMode)
UnityEngine.Animation:CrossFade(String, Single, PlayMode)
UnityEngine.Animation:CrossFade(String)
makeMove:Update() (at Assets\makeMove.js:26)

Despite me being a novice in Java, I know its telling me a did not make a split animation for “run”, even though I’ve made one, I also named the input as “Run”.

Any help would be greatly appreciated!

-Max

388734--13372--$sendtounityforum2_run_202.jpg
388734--13373--$sendtounityforum2_run2_186.jpg

“Run” != “run”. You have it mis-spelled (capitalized) in your script.

Thanks Laurie,

Do i not have it specified that the *.GetButton(“Run”) is the input name, and animation.CrossFade(“run”)is the split anim name?

…I guess I’m a little confused.

Does the Animation have a “run” animation?

I know it’s kinda goofy, but when I add an animation and reimport, I have to manually add the new animations to my objects.

Oops, sorry, you’re right. Are you sure that (a) the game object the script is attached to is the one that has that animation; and (b) that the script is not attached to any other game objects?

Laurie and Vicenti, I’m greatful for the help.

I’m still having the same problem. Laurie, i double checked what objects have the script running in my hierarchy and it seems the only thing that has it applied is the character. There is a 12 frame animation to which im calling as run in the split anim window. Vicenti, when you say you manually add the new animation to the objects, do you mean when you have seperate animation files? I’ve built all the animation in one file and split the animation by frame.

Thanks again guys,

Max