Game Development Reference
In-Depth Information
Let's get set and show them
The next step in our Control script is to set up our controls to be able to customize
what they do, and display what each control does.
Adding variables for each control
At the top of your script, after your other variables, add these new variables:
public string PC_Move, PC_Rotate, PC_Item1,
PC_Item2, PC_Item3, PC_Item4, PC_Inv, PC_Pause,
PC_AttackUse, PC_Aim;
public string Xbox_Move, Xbox_Rotate,
Xbox_Item1, Xbox_Item2, Xbox_Item3, Xbox_Item4,
Xbox_Inv, Xbox_Pause, Xbox_AttackUse, Xbox_Aim;
We will use these variables to display our controls on the screen. Later, we'll use them
for customization as well. Add this code to assign the default values to our new vari-
ables:
void SetDefaultValues()
{
if(!isControllerConnected)
{
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";
}
else
Search WWH ::




Custom Search