Magazine/Reload

How would you go about setting up magazine sizes and reloading? I noticed an animation called “Inspect” which isn’t a reload animation, but I’d like to challenge myself to use it as a placeholder reload animation, along with setting up 30 bullets in a magazine. I’m guessing you need to set up an extra variable for MaxAmmo, and do some maths.

Thanks :slight_smile:

I added 2 text boxes in the corner of the CharacterHUD and named them ‘Ammo’ and ‘MaxAmmo’

image

Then created Bindings for them here

Screenshot 2022-05-15 105223

Edit the bindings
Screenshot 2022-05-15 111401
to look like this


Set up the key binding ‘R’ for reload in Project Settings

Screenshot 2022-05-15 112404

Make 3 new variables in FPS_Character (set the default values after compiling (I used Ammo 25, MaxAmmo 100, ClipSize 25))

Screenshot 2022-05-15 105543

Make a new function called reload and edit it to look like this

Modify your Fire weapon loop so it -1 bullet each shot and no fire with 0 Ammo

Then add a ‘Reload’ action event to call the ‘Reload’ function

Screenshot 2022-05-15 110228

The only problem is after 0 bullets gun stops working (obviously) but ammo count still goes down on click, I’ll try and fix that now.

Edit: Fixed it by adding a set ammo node after this branch

That was fun :slightly_smiling_face: (I’ll watch the video now and see how the teacher did his)

Edit 2: Had to modify the next step as well to work with this (commented there)

Very detailed breakdown of a solution, good job!

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms