Hi, I know there are simular questions to this but I still can’t get mine to work. I’ve got a basic inventory that allows me to add items to my player and when I click use on the inventory screen I want it to update my players health but no matter what it fails to call the player custom event here’s the blueprint for reference any help is appreciated.
Have you tried get player character, then casting to your bp from the on clicked button event? Instead of your c.character ref, I think that isn’t being set. I like to keep my widgets in my game state so they can communicate easier. I think this is right atleast lol
There are three ways to solve this.
-
You can define an Interface for “AddHealth(amount)” and have your UI call that interface function on the player Pawn. As long as the player Pawn actually does “implement interface” on that interface, the function will be called. That function can then invoke the event if you need it to.
-
You can get the player Pawn, and Cast Object to your specific player pawn class, and then invoke the event directly on that casted object.
-
You can put an Event Dispatcher in the GUI, and call that dispatcher in the GUI function. Then have whatever sets up the GUI bind the appropriate function on the player Pawn to that Event Dispatcher in the GUI after the GUI is created.
Can you show the code pics for that? Ty
-
Im not 100% on how to setup BPIs and when to use which nodes: Message vs Call function vs make a Function in the first Actor (or 2nd actor that I want to pass the variable to)?
-
And Im unclear in the BPI, when to use an Input vs Output?
-
E.g. if we want to send a Variable in CharBP to Widget, then do we need an Input or Output in BPI?
-
And then what is the code in the 2nd actor (receiver) = Widget, to Get/read that variable being sent by Char BP?