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.