Use string variable from Blueprint to widget Blueprint?

Hi!
(first, sorry for my english…)
I have got an UMG Blueprint widget and i would like to run another level when i click on a button.
But, each button had to return some different value in a string variable I created in the blueprint PawnClass of the second level. But, I can’t set a value to this variable from my interface Blueprint (UMG).
Look :

Here is my first UMG interface, running in my first level.
When I click on the button (BHalvor), the variable “Choix Perso” would take the value “test”. Then, the interface would be removed and the second level would be open.

So, look at my blueprint PawnClass. (It’s the default pawn class of the second level) :

But here, the condition is always false and when I try to print my variable, nothing appears, she is empty.
In my opinion, the issue come from the “object” pin of the “Cast to PawnBase” node but I tried to connect a lot of node like “get player character”, “get player controller”… It didn’t work…

Help me please!

Thank you very much for your answer
I tried what you have been said but it doesn’t work. When I search “Cast to PawnBase”, I don’t find it.
Recall : PawnBase is the default pawn class of my level.

Hey there,

although it didn’t work in your tests, you will need the “GetPlayerCharacter” node. First create it and then pull of the return of that node into an empty space of your event graph. Now search for “Cast to PawnBase” again. This time it should be able to link correctly.

If you are using Cast nodes, you will want to only search them together with a return pin that you are dragging of. Also make sure “Context sesitive” is activated at the top right corner of the context menu.

Ah ok, what is the BaseClass of that “PawnBase”? Is it APawn or ACharacter?

If it is APawn, then you can try the following:

“Get Player Pawn” instead of “Get Player Character”.

Or you can still try “Get Player Character” and disable “Context Senstive”.

I guess it is not showing up at your screen, because it won’t let you cast ACharacter to an APawn based class.

Still not…:frowning:

In fact, it is a APawn. So I tried with “Get Player Pawn” and I pull of the return of that node into an empty space.
After, I was able to find “Cast to PawnBase” node. But now, the cast is failed and I have this message :

Remove the “Cast Failed” output. If the cast failes, you are not allowed to use the return value, because it will be NULL. NULL means something like empty. If the cast failes and you still try to set the variable, it will try to set a variable of nothing. That gives you the error “Accessed None”.

And how could I avoid the cast fail ? Because the value of my variable would never change if the cast ever failes.

If you set your DefaultPawnClass in your Project Settings to this “PawnBase” class, then the cast shouldn’t fail at all :confused: