Reference variable not valid

Hey!

I’m quite new to blueprints, decided to follow tutorial on Inventory system to get some more knowledge and now I’m trying to extend this system by myself.
I’m having trouble with referencing.

I followed tutorial :
First of all, I have created few actors:


Right now I’m gonna talk about BP_Inventory.

I have some functions and variables that need to be accessed from a lot of widgets.
Almost all of these widgets, are “childs” of MainWidget.

This Main Widget is created in BP_Inventory on Event BeginPlay.

If I understand correctly, we are setting “Inventory” (BP_Inventory) on Create Widget node.
I guess because of that I can use in widgets “Inventory” ref.

Just by creating variable of type “BP_Inventory”.
I’m not really sure how this was accomplished.

Right after finishing few other widgets I decided to create Hotkeybar and this is where I have quite a problem.
In my BP_HotkeyBar - basically same type of blueprint as BP_Inventory, I have functions and variables I need to get into my widget called “HotkeyBar”.
Just so I won’t confuse anybody let’s call it W_HotkeyBar for now.
Keep in mind that W_HotkeyBar placed in MainWidget. So well I did some work and when I tried to create variable of type “BP_HotkeyBar” it didn’t work.
Tried to understand why, and I just can’t understand why or how to do it.


After debuging I know that this variable is always Not Valid.
Tried to get reference of this Actor by “Get All Actors Of Class” and ForEachLoop for variables, but this just isn’t what I’m looking for and what I heard isn’t really efficient.
Also note that BP_Inventory isn’t placed in level, just as BP_HotkeyBar isn’t.

How can I have another input in “Create Widget” node?
Is that input in “Create Widget” node even doing something?
How should I solve this problem?
Edit(Didn’t really clarify my main problem): How can I reference my BP_HotkeyBar in W_HotkeyBar?

If there is anything I didn’t tell you about or you need more info, just ask and I’ll provide needed info.

Working with what you already have, look at your 4th image above, after the create main widget node, you are setting a variable “Main widget” from there you are pulling out the Inventory widget and setting a ref variable of “Inventory widget”, do the same for the hot-bar widget. Now you will have a reference variable inside your inventory for the hot-bar.

For communication in the other direction, lot of ways to do it, one way would be to use your new “Hot-bar” variable and from it pull and set the Inventory-BP ref you have in there(you do have a variable of type inventory in there waiting?) … clean, set once now the inventory-BP sees the hot bar and visa versa.

Hello, thanks for the answer.

I think I can see a problem with this solution, or maybe I just don’t understand it fully.
I need to reference my BP_HotkeyBar(not referenced anywhere yet) in W_HotkeyBar(part of the MainWidget).
If I would create new variable “Hot-Bar” widget, now I can pull off BP_Inventory, but in BP_Inventory I don’t have reference to BP_HotkeyBar.

Oh sorry, missed that, assumed hotbar logic was in the inventory-BP and not a separate BP,

I would create the inventory as an “Actor Component” and include all related logic within the one blueprint, and attach it to either the player controller or pawn.

But with your current setup:

All you need to do is decide how you are going to spawn the BP_hotbar. and set a ref same as you did with inventory spawn, probably from inside the BP Inventory, and after main widget spawn, get a refer to this spawned BP and "set it in the reference variable for the hotbar widget.