Our game Sommeliers has gone through all the same process leading up the test like any other that i have been part of has. One part in particular is the use of a controller for the game play. This was something that i work on in a previous SHMUP i had work on, but looking back on this game you would have to use the mouse to start the game then the players would have to pick up a control. This is not how you play game, all input are from the on device and it allow player to stay engaged and not hit a wall in the flow. So when this navigation of a game feels right player will enjoy and not be frustrated.
With this menu the was a green indicator to show players what was highlighted and once players moved the controller thumb stick they would see the highlighting move down the menu and the A bottom would have them access the sub branches of this menu.
This is what every game dose, but as a designer and developer, lets just say i had me scraping my head. But i didn’t have to start from square one. One of the task that i had finished of previously for the project was that menu hook up and functionality. So all the button function and scene set up was there for me to work out how this connects to controller.
New to me was the Event System with in unity. So i know there is an event system and it governs events, OK done moving on. Ha well yes, but no. So this is where you can set all the defaults of input for navigation and selecting with in you unity scene.
From this you can also limit the timing between button presses and also the directions of the thumbs stick. So if you want to limit players to only move up and down menus that is possible.
This setup is an easy element once you know it and how it interact with game objects and element in a scene. At the top of the image above the is a first selected game object which in this case was the start button. However an issue that i faced was once you selected on of the buttons on this start screen you UI element like button would not be highlighted and would be unable to be selected and press to perform functionality.
So this became a problem to solve. The first few thing i tried like calling the game object that was the button i wanted to select, and do it that way didn’t work and trying to switch the scene first selected button was something i tried with out any success but i wasn’t far of it though.
So there is something that i didn’t know i need but fit my situation. With the event system you are able to call on the first selected button. I made a list of the first selected buttons that i wanted. This was because is wasn’t loading a new scene for each menu to have a separate FirstSelectedObject for each one. So this list was how i was able to achieve this within one scene and work alone side the activating and deactivating of the menu canvases. So i was about to set a new FirstSelectedObject each time i need a different button that i wanted to be highlighted on different canvases.
One other element i added and which was something i found researching the FirstSelectedObject problem above.
A problem that people had found with using a controller in a unity game scene was that if the mouse was clicked or move it would some times break to controller input. So this was something that i looked into add in out game. As this wouldn’t be a issue with a build of the game i thought i would do this so that if i had any dramas with this and have myself thinking that there was something else that has broken.
This wasn’t something that i needed for our project but as scripting is an area that i need to become more fluent with i decided to attempt this little task to help my self out.