Game Development Reference
In-Depth Information
{
PC_Move = "WASD";
PC_Rotate = "Mouse";
PC_Item1 = "1";
PC_Item2 = "2";
PC_Item3 = "3";
PC_Item4 = "4";
PC_Inv = "I";
PC_Pause = "Escape";
PC_AttackUse = "Left Mouse Button";
PC_Aim = "Right Mouse Button";
Xbox_Move = "Left Thumbstick";
Xbox_Rotate = "Right Thumbstick";
Xbox_Item1 = "D-Pad Up";
Xbox_Item2 = "D-Pad Down";
Xbox_Item3 = "D-Pad Left";
Xbox_Item4 = "D-Pad Right";
Xbox_Inv = "A Button";
Xbox_Pause = "Start Button";
Xbox_AttackUse = "Right Trigger";
Xbox_Aim = "Left Trigger";
}
}
We will set these variables in a function because later we will use this function again
to reset the controls if they are customized. The function uses our isController-
Connected variable to determine whether a gamepad is plugged in or not, and then
assigns the appropriate data.
Adding a function to display the variables
Next, we will use the OnGUI function to display our controls onto the screen. We will
create a menu that will show each action and their controls for a PC and Xbox 360
Controller, very similar to the table shown at the beginning of this chapter. Add this
code to the bottom of your script:
Search WWH ::




Custom Search