The Pause Menu was something I struggled with. This is because, in VR, you can't traditionally call a Widget Blueprint in front of the player, as it ends up way out of the player's viewport, something I found out the hard way. To combat this, in my pre-production, I declared that the Pause Menu would spawn from the player's watch. While I thought this would be easy, it ended up being extremely difficult, and took a lot of trial and error, including code I'm fairly sure there was a simpler way to do.
First and foremost, I designed the actual Pause Menu itself. Originally, the Exit option was on the "Game" Popup, but I then later gave Exit it's own menu.
I then ported these Widgets into Unreal. For the score and round, I binded these to the variables from the Game Mode and the Player's Blueprint.
To have the player open the menu, I took a function to spawn the Menu Class if the player presses the Joystick.
The Menu Class is taken from the VR Template from Epic Games, however, I've had to majorly add to it to accommodate this Menu.
First of all, by default, the Menu Class will just spawn the first page of the Watch's Menu, as set by me.
However, what I did with this Menu was have it so there were four different tabs, Game, Scoreboard, Options & Exit. In a non-VR game, I'd just be able to change the Widget being displayed in the viewport. However, since Widgets don't work in VR Viewports, I needed to manually change the menu through Booleans and Casting. This was an extremely tedious process, but I eventually figured out the answer.
First of all, for every page, I set up a Boolean for all the potential pages the player could exit to from the page they were on. For example, for this page here...
The player would be able to go to the Scoreboard, Options and Exit menu from here. This means that, depending on what option is selected, a new Boolean would open.
Then, if the player wanted to Enter the Scoreboard Menu, we go to the Menu class.
An event tick constantly calls every possible menu the player can switch to. Since we're trying to Enter the Scoreboard Menu from the Main Watch Menu, we'll go to Watch Popup Scoreboard.
This event casts to the Widget, and sees if the IsScoreboard is activated.
When it sees that, it sets the Widget to be the Scoreboard by setting the Widget.
Every single possibility here has a custom event, which took a lot of work, to say the least.
However, after a lot of testing I can say that the Menu is fully functional, and the player can freely switch between menus within it.
Comments