Alternate keys for thrust and rotate

[Question] I let my youngest son play a little, but as he has no left hand (yes you read that correctly), I wanted to include an option to use the arrow keys on my keyboard (just off to the right of the space-bar). Not the numpad arrow keys (4, 6, and 8), but the 4 separate arrow keys. Here is a copy of the code I used:

else if (Input.GetKey (KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) …

This is for rotate right, but I used a similar OR statement for rotate left on LeftArrow, and thrust on the UpArrow. Was a little surprised when it did not work…however the numpad (keypad) keys 4, 6 and 8 did work. This is better than “A” and “D” for my son, but I wanted to use 3 of the 4 arrow keys. I see there is a separate KeyCode.Keypad6 (as a substitute for the “D” key), but when I used this in the code the keypad6 did not respond. Why does ArrowRight work from keypad6, but not when I use KeyCode.Keypad6? And how do I get the code to respond to the actual arrow keys?

[Solved] Ok…this is prime example of rubber ducking. About 2 minutes after posting the above question, I had an epiphany. The problem described above was resolved when I turned on NUM LOCK. None the less might be a good idea to include alternate keys, even if mentioned as a passing comment in a future instructor hangout video.

@Sorendark, glad you solved the problem. Later in the course I’m sure Ben will cover the CrossPlatformInputManager (a Unity standard asset), which will then allow you to remap the control keys to whatever you like without having to explicitly write the the keybindings in code.

If you’re feeling confident then you can skip ahead and learn about these on your own, or wait for the course to get you there.

That approach will massively improve your games for your son, as the ability to remap keys is one of the first principles for accessibility.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

Privacy & Terms