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 ). Here is what I have (I will number blueprints in execution order for your convenience)
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.
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
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);
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
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.
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
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.