Event Dispatcher not firing event
In my game I created an ActorComponent to store and handle player abilities. Whenever an ability is added (or removed) an event dispatcher is called to signal, that the abilities have changed (see screenshot)
In my ability menu widget I bound a custom event to the event dispatcher, so the UI knows when to update itself, without using any ticks (see screenshot).
Whenever I call the function on the blueprint everything runs and the dispatcher is called (confirmed that already). However: The UI does not receive the call, even though it is bound before the AddAbility function runs. Now, when I do the same in the PlayerCharacter blueprint, the call is received and the custom event called.
Where is the problem in my setup? What did I miss, or is this a bug?
asked Jul 04 '16 at 06:59 PM in Blueprint Scripting
I believe I know what the problem is. For the OP, his cast to the player state blueprint is failing. So in other words, the flow of execution stops at that point. It never reaches the bind event. I can see more wrong with that original picture than what I just mentioned, but that's beyond what matters at this point. I'm not entirely sure why he was trying use the player state for that logic but even when I made a custom game mode and set it to use my custom player state, the cast still fails. I would suggest in that context to use the player character for that particular logic.
First create the event dispatcher inside the player character and then make sure that you use the player character blueprint as the target for the event dispatcher binding. Any event dispatcher target has to be a reference of the blueprint where that binding is created. That is one of the other problems I noticed with the op's logic.
Aside from that, if you cast to the current player character bp that you use in your game the cast will never fail and will see that the bind event works.
I included a couple screenshots of some logic I put together to show how event dispatchers are supposed to be used.
If there is still confusion or if it seems like I may have misunderstood the questions here, please let me know.
Follow this question
Once you sign in you will be able to subscribe for any updates here