Game Development Reference
In-Depth Information
To add a little more control, you can make the character go backwards with minimal effort. The Vertical
input generates a -1 when the player presses the s or down arrow keys. To make him go backwards
without a back-up animation, you simply set the [playback] speed of the clip to a negative number.
1.
Press the s key or down arrow, and look at the value reported in the console.
Note that the value ramps up and down rather than going directly to 1, 0, or -1.
2.
Right-click over the SC Walk state in the Animator view, and select Copy.
3.
Right-click again, and select Paste.
4.
Rename the new state SC Walk Backward in the Inspector, and set the
Speed to -0.5 .
5.
Create transitions to and from the backwards and the idle states (Figure 6-38 ).
Figure 6-38. The new backwards state using the SC Walk clip with a negative Speed value
6.
Set the transition from idle to backwards to Input V Less than -0.1 .
7.
Set the transition from backwards to idle to Input V Greater than -0.1 .
8.
Click Play, and walk the Scarecrow forward and backwards in the scene.
The controls are extremely minimal, but you can now see one means of moving a character with
Mecanim and some animations. To turn the character, you could add an animation with the turn built
into the Root motion, or you could let the mouse do the rotation and send the turning velocity back
to Mecanim. Using a Blend tree, it would time the animation to match the velocity. Although the
functionality is beyond the scope of this topic, it is something worth exploring at some point.
Meanwhile, the Scarecrow really doesn't have to do anything in this scene other than hang around.
1.
In the Animator view, right-click over the SC Hanging Out state and select
Set As Default.
2.
Press Play.
Search WWH ::




Custom Search