Page Info
Engine Version:

2. Required Character Setup

Choose your OS:

On this page, we will work on our Character Blueprint by adding the variables that will be passed to the HUD later in this guide. We will also add some conditions to determine how many times the player can shoot at each rock that is launched.

Character Setup

Let us get to work on our Character Blueprint.

  1. Inside the Content Browser under Content/FirstPersonBP/Blueprints, open the First Person Character Blueprint.


  2. Inside the graph, delete the Stick Input, Movement Input, and Jump sections so that you only contain the sections below.


    For our sample game, we only need to allow the player to turn and shoot so we have removed the other script to clean up our Blueprint.

  3. Right-click in the graph and search for and add the Event Begin Play node.


  4. Drag off the Event Being Play node and search for and add the Create Widget node.


    We are going to call our HUD Widget Blueprint upon begin play of the game and display it.

  5. On the Create Widget node for Class select the HUD, then off the Return Value, use the Add to Viewport node.


    Our HUD will now be displayed and we need to create some variables to pass to it. Let us do that now.

  6. In the MyBlueprint window, click the Add Variable button.


  7. Select the new variable, then in the Details panel, rename it to IsActive and make sure it is the Boolean type.


  8. Create another variable, rename it to SpawnLocation and make the type a Transform.


    This variable will be used to tell the rock where to spawn and will be updated from the level.

  9. Create another variable, rename it to Pulls and make the type a Integer.


    This variable will hold the amount of rocks left the player can spawn by button press.

  10. Create two more Integer variables, one called Shots and the other called Score.


    Your added variables should look similar to above.

  11. Click the Compile button, then in the Details panel for Pulls set its Default Value to 10.


  12. Set the Default Value for Shots to 3 and Score to 0.

Firing Weapon Setup

Here we are going to make some minor changes to how many times the player can fire a shot per pull.

  1. Find the InputAction Fire event and drag off it and add the Do N node.


    This node will execute the script following it a set number of times (allowing us to control the number of times the player can shoot).

  2. Set the N to 3, then while holding Alt drag in the Shots variable from the My Blueprint window and reconnect the nodes.


    Following the Shots node, connect the Set back to the Montage Play node.

  3. While holding Control, drag in the Shots variable again and connect it to a Integer - Integer node (set to 1) and connect as shown.


    Here we are setting shots to decrement by 1 each time Fire is pressed.

  4. Right-click in the graph next to Shots and add a Custom Event called ResetShots.


  5. Alt drag in Shots and set it to 3, then connect it following the Custom Event and into the Reset on the Do N node.


    When this custom event is called, it will set shots back to 3 and reset the Do N node so that it can be executed again.