Displaying ammo and reload animation

I’ve created a reload function that not only depletes ammo count but depletes clip amount after each reload until empty. Additionally, I created a blend space for the reload animation.

To begin with, I created 4 integer variables (one of which I will be editing in to update stored ammo clips later on)

Ammo - Set to 30
Max Ammo - Set to 30
Clips - Set to 15
Max Clips - Set to 15

Firstly, I cloned the function of displaying ammo shown in the lecture to display clips


I collapsed both in to their own functions to be used elsewhere

The function of displaying the ammo is exactly the same as in the lesson so I won’t cover that. I also created a secondary clip text object in the HUD called “Clips” and set it as a variable. This will display remaining clips which will be depleted after each reload.

I then created a function called Reload in FPS_Character

This function passes in ammo and checks if ammo is less than max ammo. If it is then we set the ammo to be equal to max ammo. on the same branch node we check if their remaining clips are greater than 0. If they are then we allow the reload to take place. following from this, we subtract 1 from the clips count each time a reload is performed.

Finally, we pass in the two functions to update the HUD count

Finally, I happened to have a few additional animations so I hooked up a reload animation by creating a Montage and assigning it to Weapon Slot. From here I was able to call the reload input action and pass in the montage play followed by the reload function.

End Results:


Privacy & Terms