Tracking the ammo and targets eliminated
To get our UI to respond to the player interacting with the environment, we need to modify the player and target Blueprints. Let's start with the ammo counter to decrease when the player fires a shot from their gun.
Reducing the ammo counter
We need to modify the player fire logic so that the ammo counter is decreased when the player fires their gun. Follow these steps:
- In the Content Browser, access the
/Content/FirstPersonBP/Blueprints
folder and double-click on theFirstPersonCharacter
Blueprint. - Find the large series of Blueprint nodes contained within the Spawn projectile comment block. We want to ensure that the counter tracking the player's current ammo count reduces by one each time the player fires a shot. The Blueprint scripting required to do so looks like this:
- Find the final node in the chain, Play Sound at Location...