Link Ammo Pickup From Separate Weapon BP Class to First Person Character

PS: The widget stuff goes in the parent, because it’s always the same :wink:

I GOT A SOLUTION!!

There may be more efficient ways, I’m not sure, but I found a way to get this working and it doesn’t involve a whole lot actually (No arrays or anything like that in the weapon BPs)

So when looking deeper into the functions within the ammo widgets I created, I noticed that I can also create bindings for the color and opacity of the text, like how I made the binding for getting the text to get the amount of ammo and display that.

So I did this in all 6 ammo widgets (One for each weapon that uses ammo of some sort). I set it up so that when there is a normal amount of ammo left, it remains the default color. If the ammo is running low, it changes to red. These colors are stored as slate color variables that are plugged into the return nodes at the end.

This is just the shotgun ammo widget for example:


From there, I then need to of course only show the ammo counter that corresponds with what weapon is equipped. Well because all of that code is setup in my First Person Character BP, I placed all my ammo widgets in to the main HUD widget (Bottom right) and in the same color and opacity tabs for each ammo counter, I made a binding where I casted to the player, got the currently equipped variable and then if that value is equal to, let’s say 1, then the opacity of the widget will be 1 or visible. If not, the opacity will be 0 or invisible.

Shotgun Example:


And boom! It works for all weapons!

I’ve said it before, but I’ll say it again. I can not thank you enough for all of your help. Even though I found another way, you taught me extremely valuable information that I will hold onto for as long as I can down the road. Thank you for everything! :grinning:

1 Like

Good to see you got it working :star_struck:

1 Like