Rob - Managing User Input - Senior Production Blog Post #9

In Frog Snatchers, we have Keyboard and Gamepad input. At some point in the production process, I brought over my Xbox Input Manager from Planet Snatchers, which (with a few properly placed bools all around the game) allowed us to use either control scheme to play the game. While this worked for QA purposes, it still was a far from perfect system. You could play the game with both control schemes simultaneously. Additionally, we had no way to remap controls, and nearly all of the Input was hard coded in each script.

To solve this, I started on a new "InputManager" script that I tend to refer to as a Middle-Man Input Manager. It takes Unity's Input.GetKey(KeyCode) and my Xbox InputManager's Input calls, and delivers them to our scripts in an identical fashion. The difference here is that it knows if the user wants to play with Keyboard or Gamepad, and lets them freely switch. Additionally, it allows users to remap the controls. 

InputScreen.PNG

The screen here is obviously not the most beautiful thing to look at, but it's fully functional. You can remap almost every action in Frog Snatchers, for Keyboard and Gamepad separately! We also present the option to change the movement keys from WASD to Arrows, since that's a piece of feedback we've received in the past.

I don't want to get too technical in this post about the remapping process and the abstracted Input class, because I'd honestly really like to redo it eventually (not for Frog Snatchers). The systems here work, but I still think they could be improved a great deal.

Instead, I'll just show how the playerCharacter and other gameObjects read Input from this Middle-Man now:

 Instead of calling Input.GetKey(KeyCode.Space), the Input Manager will already have a bool representing that (with the user's preferred key -- not necessarily Space), which we access with the code highlighted in yellow

Instead of calling Input.GetKey(KeyCode.Space), the Input Manager will already have a bool representing that (with the user's preferred key -- not necessarily Space), which we access with the code highlighted in yellow