Hello,
Took me a while to put something together but I think this might just work for you. This will require quite some work so be ready to spend some time on this.
First you will need to create a widget blueprint. This will be your HUD, for me it just displays current ammo and plays an animation when ammobox was picked up. Create new variable (integer) and call it QtyPickedUp.
You don’t need all this stuff inside the widget and I will not be showing you how to create animation for this as you can find a tutorial on YouTube. It’s not hard, really. Okay maybe a little but I believe in you.
When widget is created you cast to your character and set a reference to it. You will need it to access the variables from inside your player character (for us it’s ammo)
Third and Fourth images are the bindings for both text fields (x99, ammo(Text Block))
Once you got your Widget setup (you can just have a text for now to see if it’s working) go to your player character (for you could be Third/First Person Character) and create a new integer variable called PlayerAmmo, default (5). Follow the screenshot below. You will need to create a reference variable as it will be used later on to access code inside the widget and set a variable.
Assuming you have your AmmoBox actor ready with a collision component and a mesh inside. You will need a new variable (integer) that will hold a value of Boxes that can be picked up (for me 5). Select newly created variable and tick Instance Editable. This will allow you to set the variable on the actor from the editor without having to open the actor blueprint.
Follow the scripts from screenshots. I’ll do my best to explain and I put some comments around to make it easier.
When your character (for me it’s PlayerCharacter) overlaps collision box for the AmmoBox it triggers a script that sets the variable inside the widget that is used in binding function. Now using a newly created reference to player character you can get and set variables inside your character. You can also play animation from here by using a reference to player character that in turn has a reference to HUD which you can now access and execute a function from inside the widget, and set a variable of how many items were picked.
I will admit this isn’t the best setup but it should work for you. There are a lot of things that could be improved here but I don’t want to make it over complicated, I want you see a working example and maybe come up with something on your own, or modify this to suit your need.
I’m sure you will have some questions and I will do my best to explain.
Remaining screenshots in comment due to limit of 5 screenshots per post.