Game Development Reference
In-Depth Information
This button, when clicked, will call the SwitchControlScheme() function and
pass it a letter determining the control scheme being used.
Cycling control inputs
Our next method of customization will let the player click on one of the GUI buttons
in our controls, and pick another control to switch it. To start off, we'll add variables
that we'll use to hold the original values of our controls. The last two variables will be
used to allow us to customize our controls:
private KeyCode orig_pcItem1, orig_pcItem2,
orig_pcItem3, orig_pcItem4, orig_pcInv,
orig_pcPause, orig_xInv, orig_xPause;
bool ShowPopup = false;
KeyCode PreviousKey;
In the SetDefaultValues function, assign these variables to our previous control
variables in both the if and else statements:
orig_pcItem1 = pcItem1;
orig_pcItem2 = pcItem2;
orig_pcItem3 = pcItem3;
orig_pcItem4 = pcItem4;
orig_pcInv = pcInv;
orig_pcPause = pcPause;
Assign the Xbox 360 Controller controls in the else statement:
orig_xInv = xInv;
orig_xPause = xPause;
Next, we are going to add a function that we'll call to switch our keys:
void SetNewKey(KeyCode KeyToSet, KeyCode SetTo)
{
Search WWH ::




Custom Search