Cannot access to the variable in a reference after setting it

I created a widget BP and promote to variable in my PlayerController, but after doing this, I couldn’t access any variable(particularly, I wanted to use the W_InventoryGrid) and event in my widget.

But after creating the widget, I could access W_InventoryGrid from the return value.

So I just promoted the W_InventoryGrid in my PlayerController directly from the return value, it temporarily solved the problem. But now I want to access an event in the W_InventoryMenu, and I still can’t access it. I wonder where I went wrong and how I can fix it.

When you mouse over the Set node, what type do you see?

image

Judging by this:

image

We’re still working with a base user widget class. Which means you probably promoted to variable before choosing a class:

Which would give us undesired type:


Were I to do things in a different order by selecting the class first:

image

I’d end up with matching types:

In short:

Choose class first and then promote.

See above.

Huge thanks. I never know the order in which the blueprint was originally created affects the result.

1 Like

Yeah, it’s a gotcha. Promotion looks at the class dropdown at the moment of creation and makes a variable of the type it finds. If you change the class later on, the result will not propagate and update the variable type.

Which is actually great, it would mean a whole world of pain across the project if that happened.