- Home /
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:
I would appreciate any help that you may have and if you would like more information on my problem, feel free to ask.
Answer by tanoshimi · Feb 16, 2014 at 07:45 AM
The "new" Animat*or 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: http://unity3d.com/learn/tutorials/modules/beginner/animation
Thank you for this answer! The videos really helped and my project is back on the rails
Answer by MakeCodeNow · Feb 15, 2014 at 06:05 PM
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.
When removing the animator component it made no difference and by replacing "animation" with "animator" I had unknown identifier errors for it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133615im_/https://answers.unity.com/themes/thub/images/avi.jpg)