-1
\$\begingroup\$

I want to try animating sprites with the Unity's mecanim. All the tutorials I found used bipedal humanoids, which already have the avatar for the animator component and imported animations.

What I want, is to create animations inside Unity(like in legacy) and use the animation state machine. So the question is: How do you animate a single sprite using a mecanim's animation state machine?

\$\endgroup\$
  • \$\begingroup\$ Pretty broad question. What, specifically, are you having trouble with? What have you tried that didn't work? \$\endgroup\$ – MichaelHouse Feb 27 '14 at 15:25
  • \$\begingroup\$ @Byte56 What is unclear? I mentioned in the question that I wanted to use legacy type of animations with mecanim. To which I found no tutorials which means I had no idea what to try. \$\endgroup\$ – Esa Feb 27 '14 at 16:04
1
\$\begingroup\$

Got the animation working with the new mecanim system. Something to note is that Unity does not allow physics and animations on a GameObject at the same time.

You can create legacy type animations for an object following these steps:

  1. Create a new animation controller
  2. Create a new animation
  3. Add Animator component to the object
  4. Open the object in the animation window with the object selected
  5. Click Add Curve and select Transform/Rotation
  6. Set the second keyframe y-axis rotation to 180
  7. Press play to see the animation

These animations can then be added to the animation state tree.

\$\endgroup\$
  • 2
    \$\begingroup\$ What do you mean that Unity doesn't allow physics and animations on a GameObject at the same time? This seems false as I have physics affecting animated objects in a platformer. \$\endgroup\$ – XNargaHuntress Feb 27 '14 at 16:16
  • \$\begingroup\$ @XGundam05 If you put a rigidbody with gravity on a GO it will fall. If you put an animator with an animation to it, it does not fall anymore. You have to add the physics to a parent object to allow both. Link: answers.unity3d.com/questions/337817/… If you put the set the object to a kinematicRigidbody then you can have animations but the physics effects no longer affect it. Link: docs.unity3d.com/Documentation/ScriptReference/… \$\endgroup\$ – Esa Feb 28 '14 at 6:38
  • \$\begingroup\$ @Esa I am thankful for the legacy part of your answer. I was not knowing about that and it became quite a handy to me! \$\endgroup\$ – Vivek Kalkur Feb 28 '14 at 7:28
  • \$\begingroup\$ If you want to animate with physics you uncheck the "apply root motion" box and check the "animate physics" box... Is that what you are talking about? \$\endgroup\$ – Savlon Feb 28 '14 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.