Animation-not playing

Using JavaScript:
My update function moves the character how I want, and within the if statement, I add animation.CrossFade(“animation”); but nothing plays. I then made the animations a separation function and called it from within Update, and no animation plays. Any help on animation beyond calling the animation from script would be helpful.

I’m getting this error:
there is no ‘Animation’ attached to the “First Person Controller” game object, but a script is trying to access it

Well first off, function Update() plays EVERY frame.

So you are telling the animation to play ever frame. That might be your problem.

okay, so separate function? based on tutorials I’ve seen, everything else seems fine…. but there is not animation

Well lets say you wanted to play it when you press “w”.

function Update () {
if (Input.GetKeyDown(“w”)) {
PlayAnimation();
}
}

function PlayAnimation () {
Animation.Play(“walking”); (or whatever you want to do with your animations)
}

However, it might not be a problem with your script at all, I would double check everything in your inspector as well, just in case.

I just tried the scripting like that, and it doesn’t work, I get the same error.
What should I be doing/checking in the inspector?

Ok, here is my EXACT error:
I keep getting this error when trying to script the animation:

MissingComponentException: There is no ‘Animation’ attached to the “First Person Controller” game object, but a script is trying to access it.
You probably need to add a Animation to the game object “First Person Controller”. Or your script needs to check if the component is attached before using it.
UnityEngine.Animation.CrossFade (System.String animation)
CubeManScript.walkAnimation () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CubeManScript.js:69)
CubeManScript.Update () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CubeManScript.js:39)

help?

and my walk animation function is this:

functionwalkAnimation(){
animation.CrossFade(“WalkBackwards_001”);
}

don’t worry about the fact it’s backwards, I just had them switched, it doesn’t matter

and again there is a space between function and walk, clipboard didn’t copy it, don’t know why

now I have set up the animation window, I dragged the animation into it, and set it as a transition from “any”. the animation now plays once every time I hit the play button in game view, but that’s not really what I want it to do, and the animation does not play when I press the button for the animation to play… some sort of progress but no solution

4 Errors:
1)
The AnimationClip ‘WalkBackwards_001’ used by the Animation component ‘First Person Controller’ must be marked as Legacy.

Default clip could not be found in attached animations list.

NullReferenceException: GetRef
CubeManScript.Start () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CubeManScript.js:13)

MissingComponentException: There is no ‘CharacterController’ attached to the “CubeMan” game object, but a script is trying to access it.
You probably need to add a CharacterController to the game object “CubeMan”. Or your script needs to check if the component is attached before using it.
CubeManScript.Update () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CubeManScript.js:20)

I had the same problem. Just switch from the Legacy animation system to Mechanim system and everything should work.
http://docs.unity3d.com/Manual/MecanimAnimationSystem.html

How do you switch to Mecanim?
The Legacy system allows control of angles though, I might want that…

I added animate to Legacy, since Mecanim was not a listed choice. However, my animations are still not playing in game, and I keep getting the error:
MissingComponentException: There is no ‘CharacterController’ attached to the “CubeMan” game object, but a script is trying to access it.
You probably need to add a CharacterController to the game object “CubeMan”. Or your script needs to check if the component is attached before using it.
CubeManScript.Update () (at Assets/Standard Assets/Character Controllers/Sources/Scripts/CubeManScript.js:29)

Lets if u wonna play a anim after fire1 key pressed, this is how it gonna be.

var anim : AnimationClip;

function update (){
if(Input.GetButtonDown(“Fire1”)){
animation.clip = anim;
animation.play();
}
}

I’ll try that. Thank you very much for the response.
Quick question. Has : animation.Play(“blah”) been deprecated or something? because I have been trying that and animation.CrossFade(“blah”)
?