Im new to UE, so please be patient
I managed to setup ammo deduction with each shot, but can’t get it to refill after picking up magazine froom the ground. My blueprints look like this:
Ammo counter deducting 1 from current ammo with each shot
Now i think it’s a problem with overlap event, becouse the cast to BP_Rifle fails here. I don’t know how to make it work tho. BP_Rifle comes from starter content’s first person game.
It’s proobably easy for you but for me it’s black amgic even with tutorials and a book on UE.
When I am figuring out new code, here is what I like to do:
make a new project
make a checklist for the key events that must happen
build the lines of communication needed to make these events happen
use print strings to confirm that things are working
If I try to do it any other way, it takes longer.
Now, more specifically to your code, the problem is that you are casting a single actor reference to two different actor classes.
You’ll have to understand what is actually happening when you cast. The easiest way to learn is just google that (e.g. search something like “unreal blueprints casting”) - tons and tons is already written and you’ll find plenty of videos as well. Once you understand what it means to cast, you’ll understand why this code is not working. I’d be happy to explain what casting means but 1,000’s of other people have already done a better job, so it’s best for you to look that up on your own.
One thing that you can do right away to help get an idea of what is happening is this:
hook up a print string before the sequence node and plug the “other actor” directly into it. That will print the display name of the other actor.
Enter play mode and watch for the other actors name to get printed in the upper left corner. What does it say?
Then, do the same after the cast nodes, on their success branches.