Download

Variable out of scope, can't figure out why

Hi, there’s a lot of threads with this title but I still can’t figure an answer.

On my Player Character (single player game, only one character), I set a Variable to reference the HUD widget:

I’ve set that variable to public (clicked the eye icon).

On another actor, I set a reference to the Player Character and then also set a reference to the HUD variable. this is done inside a macro:

Inside the macro:

When I try to use this HUD Variable later, I get the out of scope problem:
image

I’ve tried replacing all the nodes in case a reference was broken. I tried casting directly. I did ensure that the initial variable does get properly set to the widget.

Still it stays out of scope. I am a beginner so I assume I am probably just doing something weird. But I have seen some epic staff reply to similar questions and suggest there could be a bug. But those were old threads from 2014.

Any help is appreciated, thanks.

I just wanted to report, the simple workaround is just to put this function on the player character. In my case, this isn’t a problem to do so. However, it would still be great to understand why this variable is considered out of scope when I am explicitly pointing to it.