Game Development Reference
In-Depth Information
Any State
Any State is a special state provided by Unity in the spirit of DRY, discussed earlier in the “Run Like a
Zombie” section. It serves as a shorthand to allow you to transition from any of the animation states
in your controller to some other particular state. A common usage of this would be Death, assuming
your character could take a hit of some kind regardless of what animation state it is currently in.
You set up this transition just like you would any other transition, the difference being that you do it
directly from the Any State box to the Death box only once, not from each individual animation state.
The reverse is not true. You cannot transition from an animation state to the Any State because
it does not represent a unique animation state, but rather all of the animation states, so the Unity
engine would not know which precise animation state to which to transition. It is not configured
to be used as a means to transition to a random animation state. As such, if you do try to create a
transition to it, the arrow just won't stick.
User Input and the Input Manager
What's going on with this Input.GetAxis ? One of the powerful features of Unity is that you can
build one game, then deploy it to a wide variety of platforms. This presents a particular challenge
for dealing with user input, which might come from the keyboard, mouse, joystick, gamepad, or the
touch and accelerometer input of mobile devices.
Instead of having to hard-code every possibility into your scripts, Unity's Input Manager comes to
the rescue. With the Input Manager, you can configure the various input devices, then access them
all through a scripting interface as you did here with Input.GetAxis .
You get the default input axes shown in Table 5-1 when you create a project.
Table 5-1. Input Manager default settings
Input Axes
Input
Horizontal/Vertical
WASD and arrow keys
Fire1, Fire2, Fire3
Ctrl, Option/Alt,
Mouse X/Mouse Y
Mouse movement delta
Window Shake X/Window Shake Y
Window movement
In the Unity editor top menu, select Edit ➤ Project Settings ➤ Input to change these settings or add
new virtual axes. Bear in mind that as part of a good game experience, your users will expect some
standardization, where common inputs engender common actions. They expect the arrow keys and
WASD keys will control movement. At the same time, the Input Manager also allows end users to
configure the keyboard so they can adjust it to their personal preferences (Figure 5-40 ).
 
 
Search WWH ::




Custom Search