Setting a Reference Variable to the Value of a Object Reference Doesn't Seem to Work?

Hi,

I was just testing out some Blueprint communication between a Character Class and a UMG Widget.

In the ThirdPersonCharacter Class I have a variable, Object Ref, that holds a reference to a created UMG Widget (called “File”).

I want this File Widget to appear onscreen when a Button is pressed. So I cast to the Character and get the Object Ref in order to run the add to viewport node.

That all runs fine actually. If I attached Object Ref to Add to Viewport, the Widget appears onscreen exactly as I want.

However, the one thing I can’t seem to get right is having Object Ref pass its value into another Variable.

In the image I’m setting NewVar_2 to Object Ref’s value, but when I do that the Add to Viewport node won’t run.

What’s the reason for that? NewVar_2 is of the type User Widget, and, again, Object Ref by itself is able to successfully create the widget, yet I cannot seem to find a way to set a variable equal to the value of Object Ref.

I have it On Initialized here, but I’ve tried it with Construct, Pre-Construct, and in Functions as well.

Am I missing something about how these object references act, and whether or not one can set another variable to their value?

Any help is appreciated, thanks.

Did you try creating the variable inside the widget with ‘promote to variable’?

Hi,

Do you mean to NewVar_02 variable?

If so, that’s actually how I created it. I right clicked on Object Ref and did Promote to Variable. It created the set for me, and then I used the get for the Add to Viewport (I’ve tried pulling directly from the Set output too).

Something seems off here. For some reason it just will not pass the information to a new variable.

I even created a Text variable, got the widget name, stored it in the Text var, and called that var from the Cast.
The same issue happens. If I print directly from the called var, it works perfectly, but if I try to set a var within the Widget to the value of the casted Text var…it passes no value and the var has nothing in it.

I think what’s confusing me is that it’s clearly communicating fine, but it just doesn’t seem able to edit a var value in the Widget?

The only thing I can think of is that it’s somehow an issue with the Widget running the Set during OnInitialized? But even then I’m not so sure.

So you decide which widget to use in the character, but don’t apply that until you’re in another widget.

Why not wait until the button is pressed in the 2nd widget and call a function in the character to decide which widget to produce?

That definitely works and is a good idea.

I questioned this less from the actual need for a system, and more that I was curious as to why this specific setup doesn’t work. Just for future reference really. The issue I’m having is just one I can’t seem to get to the bottom of.
I feel like I’m missing something in regards to how these reference variables pass information to other variables within another Blueprint.

But yeah, good call on using the Character class.

I have no idea really. I sometimes come across much worse stuff ( thinks, level sequence STILL can’t be made position independent ), which haven’t been fixed, so…

Appreciate where you’re coming from though…

There’s a lot of little things that kind of pile up when working in UE sometimes, but, then, that could just be the limitations of Blueprints versus full C++ programming.