Game Development Reference
In-Depth Information
Chapter 1. Interactive Input
Before we start creating our game, it is a good idea to figure out our controls. We'll
create a script that will hold our inputs, and create control profiles for both the key-
board/mouse as well as the Xbox 360 Controller . Then, we'll add functionalities to
be able to switch between the profiles and customize them as well. Control configur-
ations like these are a key element to games, especially PC games.
In this chapter, we will cover the following topics:
• Creating controls for the Xbox 360 Controller
• Creating controls for a keyboard
• Writing a function to detect whether our controller device is plugged in
• Customizing our controls
• Letting players switch controls
• Switching controls with Graphical User Interface ( GUI ) buttons
• Resetting controls back to factory settings
Picking the controls
Before we start creating our game, we should decide how the player will play the
game. The controls are one of the most key parts of a game.
Mapping the needed controls
For the game that we will create, we will need several controls. Some are already
included in the input manager within Unity, while some are not. The following table
shows what default controls we will be using, and what buttons we'll use for them:
Action
Keyboard/mouse
Xbox 360 Controller
Movement
WASD keys
Left thumbstick
Search WWH ::




Custom Search