Download

Reload System

I Want To Make Each Weapon BP To Have Its Own Ammo Count.
Right Now The Reload System Is Done In The Player Character
So When I Switch Guns The Ammo Count Dosen’t Change. Any Help Appreciated




The Reload function should be in the gun. The player then would ask the gun to reload itself with the int ammo it sends it.

  • the player holds X ammo
  • query the gun for how much it needs
  • send that much → Reload
  • deduct ammo in the player inv

Should the reload function be in the child gun or the gun-base

Base Gun. The children can then override it in case they are reloaded in a different way. Maybe there’s a laser that charges in X seconds and uses no ammo, but all regular guns take slugs.

Sorry i am a beginner,How would the player ask the gun to reload.

It could look close to this (not real script, ofc):

Since you’re using Child Actor Components, you’d most likely benefit from using an interface for communication, you wouldn’t need to cast. On the other hand, since you have a base class, it’s more than fine.

Sorry i don’t understand is this what i should do.

Pretty much, yeah.

The variables that you have in the Player (ammo in mag) should really be in the gun since it’s the gun that has the mag. This way each gun has a different mag capacity / ammo type / reload speed / plays its own animations, sounds and so on.

Sorry now i cant reload.

So what does your Reload function do? The ammo in mag is still in the player, I see. The whole logic should be in the gun, including firing. Each gun can then fire in different way. The gun should also update the display with its own data, right?

It doesn’t work can you help me.
I don’t know what i did wrong.

Sorry, I cannot produce an entire step-by-step tutorial that fits right into your existing thing :(. Wish I had the time. There are too many tuts out there that cover this on YT. But the gist is a follows:

Controls are in the player:

The player asks the gun to execute some internal functionality.

  • anything that is related to the gun goes into the gun - ammo in clip, ammo left, reload speed, accuracy, damage, animations, sounds, reloading, firing logic

  • anything that’s related to the player stays in the player - how many guns they carry, total ammo, total weight, health


I’d keep the widget in the player (if you only need one at a time) and have the gun report back its current stats.

Thanks For All The Help :).