3
\$\begingroup\$

In the official Unity Animator State Machine tutorial video animation clips are dragged out from the assets folder into the animator and dropped.

I have a 3D model that i bought online to experiment with that comes with animations. I added a custom made animation as well. These all work well in my demo project. But when i add a animator to the assets and try to drag and drop animations onto it it doesnt work. I get a forbidden-sign as a mouse pointer. I try to add animations through the inspector but that does not work either.

The tutorials makes it seem so easy and does not talk anything about what animations can be used. What am i doing wrong?

\$\endgroup\$
1
  • \$\begingroup\$ Can you provide more information. Are you trying to apply the animations to the same model/object? \$\endgroup\$ Commented Jan 4, 2014 at 18:31

1 Answer 1

2
\$\begingroup\$

Ok this can be a bit daunting but i'll run you through it. With the animator component you need to use the animator tab and switch between the different states via blend trees etc. Animator tab is here

enter image description here

You create an Idle state and assign your idle animation as shown here:

enter image description here

Now all you need to do is tell Mecanim to move between the difference states depending on what you're doing, in my controller script thats attached to my character when I press Forward or backward (Vertical axis 1 or -1) my code does the following(cut down for clarity):

Note where I do anim.SetBool() that sets the variables you define in the animator which tell mecanim when to switch between the animations.

void Start() {
  // Get the animator associated with this character
  myAnimator = transform.GetComponent<Animator>();

}

void Update() {
  // Lots of other stuff

  if(Input.GetAxis("Vertical")>0){ // Forward
    transform.position += transform.forward * speed;
        anim.SetBool ("isWalking", true);
  }

  if(Input.GetAxis("Vertical")<0){ // Backward
    transform.position += -transform.forward * speed;
        anim.SetBool ("isWalkingBack", true);
  }

  if(Input.GetAxis("Vertical")==0){
        // We're neither walking forward or back so stop animating.

        anim.SetBool ("isWalkingBack", false);
        anim.SetBool ("isWalking", false);
  }



}

There's a tutorial here from Unity themselves.

Trust me I really feel your pain with this its a bit of a steep learning curve but once you get your head around it things start to get a lot easier.

\$\endgroup\$
3
  • \$\begingroup\$ Omg I didn't even check the date on this before answering \$\endgroup\$
    – Mrk Fldig
    Commented Feb 18, 2014 at 1:19
  • \$\begingroup\$ Just in case anyone else has the same problem as me: The Animation needs to be set to Generic or Humanoid, not Legacy, in order to be accepted into the Animator thing. \$\endgroup\$
    – AzulShiva
    Commented Jun 22, 2017 at 13:49
  • \$\begingroup\$ Yeah I forgot to mention that , it's a royal pain in the ass when using 3rd party models - good catch \$\endgroup\$
    – Mrk Fldig
    Commented Jun 23, 2017 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .