I’m trying to make a widget that shows how much ammo I have left on my gun and every time I click (shoot the gun) I lose 1 bullet so for example I go from 17 bullets to 16 bullets.
Now how would I be able to call the function to subtract that amount in the widget class from my player?
Here is my cpp file for the widget if needed for some reason:
I’m afraid I’m not following. What exactly is preventing you from calling the function in your widget? Do you have a property to the widget in your character class?
I want to call one of these functions on the widget class through my player cpp, how would I get reference to my widget to call one of these functions? If that makes any sense, I’m still new to unreal and c++ lol
Then I’d need to see where you create the widget. When you create your widget, assign it to the property above on your character. If it’s the player character, there are methods to get it. If it’s another character, there are also other methods to get it but it’s a bit more code (doable in both C++ and BP). In BP, there’s GetPlayerCharacter node for example.
Sorry for the super late reply I got super busy with exams. I tried putting the ammowidget in a uproperty like you showed but when I add the ammowidget in my bp character and hit compile the ammowidget just disappears from the uproperty and gets set back to none. You know what could be causing this by any chance?