This article will show how the basics of animating in Autodesk Maya work and how to export your animated object ready for use in Unity. For this demonstration we will create a box that has a lid that opens. In game this animation will be triggered by a key press.
Make sure you model your box with two distinct parts, the lid and the base. I know this sounds obvious but we only want to animate the lid.
We now need to move the pivot point of the lid to act like the lids hinge. To do this select the lid and the move widget (w) and hold (d) on your keyboard. This allows you move the pivot point to where the hinge would be (see example image below)
In the timeline panel at the botom of Maya set the required frames to 30. We are going to create two animations within this one file, an idle animation (frames 1-6) and an open lid animation (frames 7-30). We can then split the animations up when we import the asset in to Unity.
Select the lid object and making sure it is roteted to shut, select frame 1 in the timeline and press (s) on the keyboard. This will add a key frame to the timeline. Now select frame 6 and press (s) again. This has created our idle animation.
Now rotate the lid so that it is in the open position. Select frame 30 and add a keyframe by pressing (s).
Test your animation by using the playback control panel on the bottom right of Maya.
Now we are ready to export the gane asset ready for use in Unity. Select frame 1 in the timeline, then select both the lid and base of the box. goto File > Export Selection and export the asset as a .fbx file.