Game Development Reference
In-Depth Information
Customization is key
It's time to customize our controls! We'll go over a couple of ways to add customiza-
tion to our controls. Unity doesn't allow us to edit the input properties while in-game,
so we will create a couple of ways to change the controls ourselves. In our game, we
will utilize both these ways.
Swapping control schemes
Our first method will be to switch between preset control schemes. To start off, we'll
add a bunch of variables that we will use for our controls:
string ControlScheme;
public KeyCode pcItem1, pcItem2, pcItem3,
pcItem4, pcInv, pcPause, pcAttackUse, pcAim,
xInv, xPause;
Since we can't modify the input properties, some of our controls will not be custom-
ized, such as movement, camera rotation, Xbox 360 Controller attack/use, and Xbox
360 Controller item switching. Next, we will need to set some default values to these
variables; we'll modify our SetDefaultValues() function to look like this:
void SetDefaultValues()
{
ControlScheme = "Scheme A";
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";
Search WWH ::




Custom Search