Changing and refining input controls 

When we develop games using Unity, we have several options for gathering user input during gameplay. Here is a list of those input options:

  • Keyboard
  • Mouse
  • Joystick
  • Touchscreen
  • Mobile device movement sensors
  • Microphone
  • Camera

As we stated previously in this chapter, we will be using the keyboard as our sole input device for the Cucumber Man game. Let's take a look at where you can make changes to the input controls for your game if you want to experiment or simply want to change the way users interact with the game. We will use Unity's input manager for this.

The input manager for your game project is accessible, as illustrated in the following screenshot, by selecting the Edit | Project Settings | Input drop-down menu selection:

This results in the input manager being displayed in the Inspector panel. There, you will find the relevant virtual axes for the game. In the following screenshot, the horizontal virtual axis and vertical virtual axis are displayed side by side. You can see how the keyboard's WAS, and D keys are set for controlling horizontal and vertical movement. For example, the W key is identified in the vertical virtual axis and is assigned to the Alt Positive Button, which means it is an alternative button for moving forward. While the primary Negative and Positive buttons are listed as using the left and right arrow keys for horizontal movement, and the down and up arrow keys are used for vertical navigation, we will implement the W, A, S, and D keys as our default method of moving the Cucumber Man character through the game world:

The input manager enables us to determine all of our input controls, and is where you can set your mouse, keyboard, and joystick inputs. An additional setting available in the input manager is for the jump functionality. As shown in the following screenshot, the jump functionality has the keyboard's space bar as the positive input device. You will note that there is no Negative Button assigned as it is assumed that the character can only jump up, not down:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset