Animation not playing correctly

I am brand new to Unity and I am attempting to learn some very basic things. I have a object which I have created an animation for that swings it. I have added the animation to the object, and I have added a script to the same object which is as follows:

function Update ()




From reading other posts and watching tutorials I don’t see anything I have done that is wrong. I have mapped the Attack key in the inputs to be r, space, and z just to test different buttons but none of them actually play the animation. I have triple checked the names for the input key and the animation.

If I check the Play Automatically box it will play the animation when the game first runs but will never play it when I hit the Attack key.

On a side note, I have attempted using Debug.Log(“I ran”) in the if statement but it never shows anything. Though I have also tried placing this code in other if statements I know are running and they also never output anything. I have never coded with Javascript but I am familiar with Action Script. From reading around it seems the Debug.Log() should do essentially the same as trace() in AS. Am I doing something wrong with this piece of code? Is there an easier way to test if an if statement or loop is actually running?

You need to use GetButtonDown (returns true one time; GetButton returns true while the button is held, and sending a Play command every frame results in the animation playing its first frame only).

As for debug logs not showing up, is your console open? (control-shift-c, or Window > Console) They should show up in there; check your collapse option button (in the console) as well.