Displaying the menu

Now that our menu has been created, we need to tell the game when to show it to the player. As we called our HUD objects from within the FirstPersonCharacter Blueprint, let's go ahead and call this menu from the same location. Open FirstPersonCharacter in the Blueprints folder.

We are going to need to trigger an Event that will signal the end of the game. Before we even determine what that signal will be, we can create a custom Event node to represent it. Add a custom Event node to some empty graph space and rename it End Game.

When the victory condition is met, we want to stop the player from continuing to move around the game world. To do so, attach a Set Game Paused node to our Event and check the Paused checkbox. Next, add a Get Player Controller node below the End Game Event node. Drag out its Return Value output pin and attach it to a SET Show Mouse Cursor node. Check the checkbox next to Show Mouse Cursor and attach this node to the output execution pin of Set Game Paused. This will enable the player to regain control over the mouse cursor after the game is paused, as shown here:

Now that we have stopped the game from playing, we want to actually display the menu. Attach a Create Widget node to the end of the chain and select WinMenu from the Class dropdown. To conclude this Blueprint chain, drag a wire from the Return Value output pin and attach it to an Add to Viewport node:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset