New animator system issues (unity 4.3)

I’m having major problems working with the new animator system in unity 4.3 and wanted to know if anyone could give a quick bit of information on how I could do this:

I have created animations for the shaking of the camera as the player is walking and sprinting. At the moment when I click play the animation plays automatically and I can’t seem to stop it. I tried to create a basic script to control the animations, as I would have done in previous versions of unity. Unfortunately, I kept receiving errors saying that there were no animations attached to the object (camera).

Here’s the script I made:

#pragma strict

function Update () 
{
	if(Input.GetKeyDown(KeyCode.W)){
		animation.Play("walkingAnimation");
	} else if(Input.GetKeyDown(KeyCode.W) && Input.GetKeyDown(KeyCode.LeftShift)){
		animation.Play("sprintingAnimation");
	}
	
	if(Input.GetKeyUp(KeyCode.W)){
		animation.Stop("walkingAnimation");
		animation.Stop("sprintingAnimation");
	}
}

Image of camera’s (game object to animate) animation setup:

[22227-animation+problems.png|22227]

I would appreciate any help that you may have and if you would like more information on my problem, feel free to ask.

The “new” Animator component uses a totally different architecture to the previous Animation component. You don’t directly play animation clips - you associate animation clips with states in a simple Finite State Machine, with defined transitions between the states.
You then transition through the states from code by calling, e.g.

Animator.SetBool("Sprinting", true);

I suggest you watch the introductory videos here: Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn

It’s confusing, but you need to use “animator.” not “animation.” The animation property refers to the old pre-MechAnim system, while animator refers to the new system. If you replace animation with animator and then update your code to use the new animator logic, I think you’ll be ok. Alternatively, add an Animation component and not an Animator component to your game object.