Saturday, March 1, 2014

Hotfix Time

Fixing the Webplayer input to match the Android version!

Our inaugural FeedbackFriday went very well. From the data we collected, we had about 700 rounds played by ~65 unique users. 9 of them were nice enough to leave feedback, and all of it was useful.

The most consistently given feedback was that the WebPlayer input scheme didn't feel great. This was because, unlike the Android version where the user can tap the screen and hold to turn the plane, the keyboard controls require the user to repeatedly tap the keys down to turn. (Note: the mouse works exaclty like a 'touch' in the webplayer too, but it's awkward to try to mouse from the left to right sides of the screen in the webplayer). 

This was a simple oversight on our part because we only implemented the keyboard controls as an easier way to play the game in the Unity editor. Seeing how easy and accessible the webplayer version is, though, we will probably pursue it as a release platform. 

The (small) difficulty with getting the keyboard keys to work the same as the touch controls was going to be getting the 'interval' timing mechanism implemented. It was not going to be as simple as "if(keyDown(A)) { moveLeft }" because then the plane would turn 30 times per second. 

Fortunately, I created an abstraction layer for the touch controls, which receives NGUI "OnPress" events, and then determines if we should fire a "OnClick[Start|Repeat|End]" event. All I had to do was emulate this "OnPress" event from the keyboard, and all the repeat-button functionality would flow downstream.

This is all the behavior code it took:


















Each button gameobject gets an instance of this component, and can assign any amount of keycodes to the "keys" array. This made it easy to configure [A]/[Left Arrow] for left and [D]/[Right Arrow] for right.

Now all tweaking to the touch-scheme, such as interval time, will be reflected in the keyboard scheme too.

Thanks for reading!