Sunday, August 24, 2014

[Unreal Engine version 4.4 Only] Creating a Pause Menu for UE4 with Unreal Motion Graphics (UMG)

This is a short tutorial on adding a pause menu to your game. The steps here are very similar to Part 2 of my UMG menu tutorial, but enough of the logic is changed that I decided it warranted another tutorial.

1. We've already discussed how to create a menu, so for the pause menu, create a copy of the widget blueprint you made from the UMG menu tutorial. Rename it "BP_Pause_Menu" (or whatever you'd like to name it).

2. Open your new blueprint and change the text for "Play" to "Continue." Now we need to change the binding so that if you want to pause your game, you can resume it without starting over. (We'll go back and add a pause later). Click the option to create a new binding.

3. In the My Blueprint tab, name your new function "Continue." Now, in the graph, drag a wire from the "Continue" node and use the context menu to create a "Remove from Viewport" node (this will hide your menu when it's time to continue). 

Drag a wire from the "Remove from Viewport" node and use the context menu to create a "Set Game Paused" node; leave the "paused" box unchecked. Connect the "Set Game Paused" node to the "Return" node.

The only thing we have left to do is tell the game to pause and pull up the menu when we press a specific key.

4. Open up your "Player Controller" blueprint (you may be able to use a different blueprint, but this is the one I used). Right-click on the graph and type "input" in the context menu to pull up the available inputs. Choose the key(s) you want your player to press to open the pause menu.

Drag a wire from your input and use the context menu to create a "Set Game Paused" node. Make sure to check the box next to "paused." Drag a wire from that node and make a "Create Widget" node. In the drop-down box, set the "Widget Type" to the pause blueprint you created earlier. Drag a wire from the blue "return value" pin and create an "Add to Viewport" node. Make sure both the blue and white pins connect the two nodes (as seen below).

Now you should have a working pause menu.

Note: If you have trouble getting your pause menu blueprint to show up under "Widget Type" in your "Create Widget" node, make sure you've compiled all of your blueprints.

No comments:

Post a Comment