Set "Ammo count" when dropping a weapon

Hello guys ! I hope you are doing well.

I have been stuck for few days on a problem and did not find the solution online.

Basically, I have a character carrying 2 weapons (Main and Side weapons). The character can drop only the main weapon. The problem is that I don’t find a way that the ammo stored in my weapon can be transferred to the one I drop. When I pick up the dropped weapon again, the initial ammo count is set on my character.

Here is a summary : I have a Character BP, a Master_Pickup BP (Parent) and several Child_BP for each weapon (shotgun, rifle and so on…)

On my character BP (see below), I have a variable Structure called Main Weapon storing all the variables of the weapon I am currently carrying (ammo count, max ammo, gun type). This structure is the same as the default class Master_Pickup BP from which I created Child BP for each weapon.

Still on the character BP, I am spawning a actor from class and select the class from the Structure so it can spawn the correct actor. However, since I have no way to input the other variable such as ammo count on this “Spawn class”, I have no idea how I can control the ammo that will stay in the dropped weapon.

I know that the problem is that the variables on my child are hard coded but how can I find a way to “set” these variables for the spawned actor ? Am I doing it the wrong way ? Should I use the Parent BP to do it ? Should I create a new Component on my character BP to stored the ammo count ?

Thank you in advance ! :slight_smile:

Sanglier Man

In Main Weapon Gun Type, you need to connect the Main Weapon Current Ammo node to the Spawn Actor.

Wait, that’s impossible. There’s nowhere for me to connect it to!

You don’t have it set up for this yet. You need to go back to the BP Master Pickup and tick Expose the Main Weapon Current Ammo on spawn. You can now connect up the Main Weapon Current Ammo node to the Spawn Actor.

Thank you Jez ! It was way easier than I thought ! :slight_smile:

That’s great! Also, thanks for marking this as resolved. You are rare! :slight_smile: