Animation plays automatically

i’m very new in unity(almost 2 weeks of work) and i have problems with the first(the only animation i created).It’s a walking animation on FPS i called walkanimation(surprise) and it’s about the gun and hand beeing slightly raised and lowered on the Y axis.Altough i have a simple working code which should call this animation only when pressing “w”, this animation plays automatically even if i’m standing.The gun(G36C) and the arm are children of the Main Camera (child of RigidBodyFPSController - unity 5.0.2),this main camera has in the inspector Animation(with walkanimation set),Animator(Controller G36C) and Walkanimation Script(walkanimation).Error messages after exiting game mode:

The animation state walkanimation could not be played because it couldn’t be found!
Please attach an animation clip with the name ‘walkanimation’ or call this function only for existing animations.
UnityEngine.Animation:Play(String, PlayMode)
walkanimation:Update() (at Assets/FPS KIT/G36C/walkanimation.js:6)

The AnimationClip ‘walkanimation’ used by the Animation component ‘MainCamera’ must be marked as Legacy.

Here is my walkanimation script:

   function Update()
        GetComponent.<Animation>().Play("walkanimation", PlayMode.StopAll);

I can’t edit my walkanimation in inspector in order to change from Generic to Legacy.I have no idea what am i doing wrong.Oh, and my gun and hand passes through walls and ground(that sounded weird).Please help !

When you only have one Animation in the Animation Controller, it becomes the default animation, so it plays automatically. If you want your character to be stand still untill something happens, you must create an empty animation and make it the default animation.