Check if a fucntion has been ran?

Hello! I’m sure my problem is a simple one, but I cannot seem to find a way to solve this problem. I am working on an inventory system. I have a container (a small lock box) with the inventory component attached. When the container is interacted with it opens both the players inventory and the containers inventory. My problem is that to close the window I have setup a function to toggle the window. I have no idea how to call the containers inventory toggle when the inventory window gets closed. Is there a way to check if a specific function has been ran? Do I need to do something with the functions outputs? I am genuinely lost. Examples below:

As you can see, the containers inventory screen stays and doesn’t leave unless I press the inventory toggle key (currently tab). I also included the toggle inventory function in case there’s some need for it. Anything to the right of where the image cuts off is just widget placement. I am completely stumped, although I am not that well versed in how blueprints work yet. Any help is greatly appreciated!

This could be done in many ways. One way would be having a Widget Manager Actor, lets call it WidgetManager _BP. Its responsibility is simply to act as the announcer of certain events through Event Dispatcher calls.

Create an Event Dispatcher in the WidgetManager_BP with a meaningful name like OnToggleInventory.

Your Player Inventory could bind to this Event Dispatcher OnToggleInventory on BeginPlay.

The Container Inventory can then call the WidgetManager_BP OnToggleInventory and afterwards Bind to the same OnToggleInventory Event Dispatcher to listen for when the OnToggleInventory gets called again. The PlayerInventory is already listening for this call and can open itself etc.

Now when the player wants to toggle the PlayerInventory it should call the OnToggleInventory Event Dispatcher on the WidgetManager and now both the PlayerInventory and the listening ContainerInventory will know about it.

When the ContainerInventory is closed it should Unbind to the WidgetManager OnToggleInventory as it is no longer necessary to listen.

You can use event dispatcher. When the backpack closes, call the dispatcher. Bind an event to that dispatcher that closes the inventory as well. (I would do the binding in the blueprint that creates and opens the backpack widget)

Note that you can link events directly or use “create event” to select an existing event. Its both kind of the same thing.

Here is an example from my project:



Actor that creates and opens the widget:

Here are some more infos about event dispatchers:


[Tutorial Video][4]