I've now added a main menu to the game, and although it was a fairly straightforward task, I wasted a few hours trying to achieve something more complex. My main issue was with the in game HUD either always displaying, or not at all. I think I know what I was doing wrong now, but I've stuck with a more simple solution. I used a YouTube tutorial for guidance.
Firstly, I created a new level and a new game mode for the menu. After opening up the menu level, I went to the window tab to gain access to the world settings, from here I could change the game mode override setting for the level to the menu game mode I hade just created.
The next step was to create a user interface widget blueprint, this is essentially where the menu lives. I kept it simple this time, black screen with buttons anchored to the bottom left. I created buttons for 'Play', 'Options' and 'Quit'. Further buttons for resolution settings were created for the options screen.
Visibility bindings were created for both the menu buttons and the option screen buttons, with an Eslate visibility variable allowing an easy transition between them.
The last step was to create On Click Events for each of the buttons. The play button simply opens the selected level, similarly, the quit button just exits the game. The options and return buttons toggle the visibility variables for the associated buttons. Finally, the resolution buttons allow the game to be played in 1080, 720 or 480. This is achieved through Execute Console Command node, and scales resolution accordingly. An example command for changing the resolution is 'r.setres 1920x1080f'. The 'f' is added to display in full screen, where as a 'w' would set a windowed screen.
Although its fairly simple to create a menu screen when you know how, I do think its a little long winded to have to create a separate game mode. Maybe there is another way to do this, but from my research it appears to be the most common solution.
No comments:
Post a Comment