Game Development Reference
In-Depth Information
Why?
What's going on? Think of animations as components of GameObjects.
Whenever an object is to be animated in Unity, Unity will create
a separate editable file (with a .anim label) that will store the
information. What this means is that the animation can be used again
and again on other objects (which is powerful in itself ). It also means
that there is this new asset that will be in the assets folder that is
important not to delete.
Note that after the .anim file is created, the Animation window will show
the record button in the top left highlighted in red as if pressed. This is
Unity's way of telling you that you can now record animations by creating
and editing keyframes.
Step 4: Set a rotation keyframe. In the Animation window, click once on
the Rotation Y text under the Transform section of AegisGroup. Along the
top of the interface is a little diamond with a plus next to it. Mousing over
this should provide the screen hint of Add Keyframe. Click this button
once. This will create a little diamond that actually records a keyframe for
all the rotation values.
Step 5: Create a second rotation keyframe to create rotation animation.
Along the top of the Animation window are the current time values.
These can be a little tricky to understand at first. The format is
Second:Frame. So 1:30 is one second plus 30 frames' worth of time.
Unity's timeline here is working as though the game is playing at 60 fps
so 1:30 would be about a second and a half. Slide the red time marker
over to any place in the timeline (besides 0). In the Inspector, change
the Rotation Y to 360 . A new keyframe will appear in the Animation
window with a yellow line to connect the two keyframes we have thus
far for RotateY.
Step 6: Test the animation. In the Animation window, next to the Record
button is a Play button. Press this to see how things are looking. Press it
again to pause.
Step 7: Adjust the timing. This second keyframe can be dragged to a new
location in time most easily by dragging the gray diamond (keyframe)
symbol on the AegisGroup line (not the yellow keyframe in the graph
section) along in time. The timeline will provide more time as the keyframe
is dragged to the right. I chose a 15-second duration ( Figure 10.50 ). Maya's
navigation commands work here too; the window can be zoomed and
panned by holding down the Alt button and dragging or middle-mouse
dragging.
Step 8: Set the animation to loop. Still in the Animation window, look at
the bottom left. Next to the Show button is a drop-down menu that will
read Default to begin with. Click this and change the value to Loop (since
we don't want the animation to stop).
Step 9: Play the game to see everything in action.
 
Search WWH ::




Custom Search