Event Dispatcher is not working

Hi, I’m sorry for asking strange question but I’m stuck with that for a full day and don’t know what to do. My event dispatcher is just not working and I have no idea why.
As I remember it was working a month ago and I haven’t made much proggress with this section from that point but now it just does not work and I haven’t found any solution on the internet (all of my problems are connected with inventory system :upside_down_face: ). Here is what I have (I will number blueprints in execution order for your convenience)


2 Widget Blueprints
image
image


Inside ‘Inventory_Notification’
image

having this code
3.


Inside ‘Main_Widget’
image

related code
1.


2.
image


So I just have no Idea :frowning:

Thank you so much for reading and your help!

1 Like

Forgot to mention just in case that this is notification from picking up an item

1 Like

The problem isn’t connected with the event dispatcher itself, I’d start by checking all other pieces of code.

1 Like

If I get it right, [Show Notification of Picked Item] and [Bind Event to Test] are in the same blueprint?
If so, you’re binding to an empty array, and you start filling up the array later. You have to bind to Inventory Notification’s event after you create it.

3 Likes

Thanks for your reply!
I also thought about that but I have the same logic of picking up an item and storing it in inventory with the same blank array in the beginning, however that one works fine

Thanks for your reply!
The problem is I don’t know where to start and what to look for.

Not sure about that. You must be doing something differently there.
Binding to events is a one-time action. Modifying the array does not automatically bind to events of new array elements, because you don’t bind to the array, you bind to each of its elements (even though blueprints allow doing it without an explicit ForEach loop);

2 Likes

Sorry I don’t want to bother you much with my code but is this enough to make a conclusion? I mean it is possible to activate an event even with empty arrays considering this or am I missing something


1 Like

In this case you pick up an item, I suppose it’s added to the array right away. Only then you open the inventory, which calls EventConstruct.
But in the widget where it doesn’t work, you create the widget first (which calls Event Construct) and only then you add an element to the array. Make your binding not on Event Construct, but after you add an element to the array and it should work.

2 Likes

Thanks, I already did it and It works fine!! But I still can’t understand why it works with my other code, it is constructing on ‘begin play’ not on openning the inventory :thinking:

1 Like

ah, yeah you are right, evetytime I open my inventory it uses event construct, don’t know how I missed that… Thank you so much!!!

1 Like

So what I think the issue here is that you are Binding Events to All NotificationSlots on Event Construct.
You are calling the event dispatcher AFTER you create “Inventory_Notification” by calling “Show Notification Of Picked Item”. Which means you are calling it when no one is bound to it. The binding you have implemented only worked on the Targets that existed when you ran “Event Construct” inside “Main_Widget”

You are attempting to bind the “Main_Widget’s” “Test” event to “Inventory_Notification” when it actually doesn’t exist yet.

So when “Item Picked Up Notification” is calling the event dispatcher, it has nothing listening to it.

Something I would try is moving the “Bind Event to test” node before “Item Picked Up Notification” in “Main_Widget’s” “Show Notification Of Picked Item” execution flow.

Hope it helps.

1 Like

You are right! Thanks :slightly_smiling_face:

1 Like