Game Development Reference
In-Depth Information
Let's switch!
Now, we'll create a way for the player to switch between PC and Xbox 360 Controller
controls.
Creating control profiles
To create our profiles, we'll need to add a new variable. Add the following enum to the
top of our script, before the class declaration:
public enum ControlProfile { PC, Controller };
Add it to your variables as well, like this:
public ControlProfile cProfile;
Finally, go to the DetectController() function. Add this line of code before the
line of code where you call the IdentifyController() function in the if state-
ment:
cProfile = ControlProfile.Controller;
After this, add an else statement to the if statement with another line of code after
it:
else
cProfile = ControlProfile.PC;
We are setting our enum variable in the DetectController() function to give us
a default control profile. This is a fast and effective way to give our player the best
control profile possible.
Search WWH ::




Custom Search