After my last post discussing the features within Unity’s Mecanim animations tools, I thought it would be a good opportunity to show you how to animate a cube using Mecanim’s basic keyframe animation system.

  1. To start, create a fresh scene 2
  2. Save the scene immediately so you don’t lose any progress. Start by adding a basic cube in the scene at (0, 0, 0).3
  3. On the cube, add an Animator component by clicking Add Component -> Animator5
  4. In the Project tab, add an Animation Controller20
  5. Link the Animation to the Animation Controller in the inspector6 (2)
  6. Initially, we need to see the animations that we want to create. So, we need to reveal the Animation window, in the Window menu drop-down.8
  7. Here, you have the Animation Window. Click “create” to start your 9
  8. Save your animation as whatever you think it appropriate10
  9. The Animation Window will come to life with a timeline, and the “Add Property” button11
  10. Mecanim works on animating “Properties”, which are components which you can already edit within the inspector. Anything you can edit in the inspector can be used as a property in the timeline. To start, add the Transform -> rotation property to the 13
  11. You’ll see that the pause/play/next button as well as the rotation properties will become red – an indicator that you are current animating that component.1415
  12. We want to animate a rotating cube, so we will place a keyframe at the half-way mark and set the Y property as 180 – a complete reversal17
  13. Finally, set the last keyframe as 360, but do so within the Animation window, because the inspector will round it down to 0, which you can see for yourself if you want! 18

Press play, and you will see your cube spinning like a top! These basic principles can be applied throughout Unity, such as to animate audio effects, and movement systems (like spinning wheels). Feel free to experiment with what Mecanim will do!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s