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.
Let us get to work on our Character Blueprint.
Here we are going to make some minor changes to how many times the player can fire a shot per pull.
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).
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.
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.
Right-click in the graph next to Shots and add a Custom Event called ResetShots.
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.