Setting a variable in UMG, that is in another Blueprint

I am a bit clueless here, I just want to set a variable when the button is clicked.

So i did what I always do when I want to set a variable -> is sticked it to the key/button, but this wont work.

I also tried to cast it to the character blueprint, but i think that i have done something wrong.

I think that something needs to be connected to “Target”, but what? I can’t put in the Charater-Blueprint there - this is what confuses me. (or maybe I am just thinking the wrong way :D)

I would appreciate any help: (NOTE: It is not connected to the “onclick” because I was experimenting around with it - I do get the String, but the variable won’t be set)

54d8dfebf855bbff4e9308aa360044d93105b967.jpeg

Thank you.

What blueprint is the variable located in? If it is the character BP, then just cast to your character, using get player controller as object.

It is located in a renamed “MyCharacter” (YK_Character)

I did this, does not work (top Cast can’t even be connected to the SET):

&stc=1&d=1434649438

Or did i missunterstand what you said? (sorry if this is true :D)

If the Character is a child class of Pawn (which is probably sould be) then you should use ‘get player pawn’.

This worked, thank you very much.

Sorry to hijack this, but what if the variable is located in the AIController blueprint? It’s not an actor so ‘Get all actors of class’ and then using for loop to cast to AiController will not work. Any suggestions?

Edit: And how would we access the widget reference from another level once the level containing this particular widget is destroyed by Gameinstance?

AIControllers are Actors.

You wouldn’t, you shouldn’t store game state on widgets permanently, the UI should merely reflect the state of the world.