Hello,
I think what I need is quite simple to achieve but I can’t find the way. I just need to be able to share a variable (the one in the image, specifically which is “chat dialogue”) from my level blueprint with a simple Widget. When this happens buttons will appear (if true) or disappear (if false) in the Widget, but I am not able to make them communicate.
If someone can show me a tutorial or image it would be great but I can only find the classic tutorial of making a widget to turn on or off lights.
my unsuccessful attempts so far to get it:
Thank you in advance, I am very novice so I ask for patience.
to be honest… you can’t. Cause you can’t cast to a level blueprint.
What you can do is:
store that variable in your Character. And in your LevelBlueprint, GetAllactorsOfClass(yourCharacterClass), get the first result and store that Reference as variable in your LevelBP.
now, you can set that bool in your Character, from within the LevelBP.
and Your Widgets can take that value of the character.
I think there can be a Way with Interfaces, too. But never tried that.
1 Like
So that’s why I couldn’t get it anyhow! That also explains the lack of tutorials.
Thank you for your response! I know it’s a lot to ask but could you show me how to do it? My video game is a visual novel and I don’t have a main character.
Anyway thanks again.
even if you have no main character, you have a player controller
so…
in your LevelBP
GetPlayerController(0) → Cast to your PlayerController class → save the casted reference
and set the bool inside the PlayerController…
same orinciple… just without a char
1 Like
Thanks again for answering so quickly @BDC_Patrick .
I’m stuck and lost:
how do I do the “save the casted reference”? I don’t know what node is used to do that that can connect to “Cast to PlayerController class”.
Once I have saved the casted reference how do I pass my variable from the blueprint to the Widget?
I’m sorry I’m giving so many problems but I’m a newbie who still has a lot to learn.
ok…
do you have a custom PlayerController in your Contents?
If not:
Right click your Contents Folder.
Add a new Blueprint
As Base class, set “PlayerController” (PC)
name the new PC class “PC_Gameplay”
go to your project preferences
go to the Maps&Modes Tab
at the top you’ll find the Selected GameMode list (maybe collapsed… just unfold it).
Set your PC_Gameplay as Default Player Controller.
In your LevelBP, delete the GetClass and CastToPlayerControllerClass… instead Use a simple CastToPC_Gameplay.
This cast has two white Execution (white arrows) and a blue PC Reference as output.
If the cast succeeds, levae OnCastFailed empty:
rightclick the blue reference output und at the Top of the popup context, you see “Promote to Variable”. Hit it.
This creates a reference variable of your PC_Gameplay in your LevelBP, you from now on can use to manipulate variables and call functions/events in your custom PC.
Important!
It may be the problem, that the PlayerController is not part of the level, directly at beginPlay.
This has the reason of the Spawning Sequence:
1st Level
2nd Gamemode
3rd PlayerController
to avoid a empty and invalid reference to your PC:
If the cast fails, add a DelayUntilNextTick
From that Delay, drag an execution line Back to the start of the cast.
This makes sure, if no PC is there, it waits a Tick and then tries again… until it finds a valid PC.
1 Like
Great answer @BDC_Patrick ! I’ve really learned a lot by following the steps and I think I now have a better understanding of how an unreal project works. I really appreciate the time you have taken to explain it to me in detail.
I happened to already have a Player created for the camera, so it was even easier.

Now I’m wondering how do I know it worked, how do I access the Player variables from the Wdget blueprint?
Anyway thanks again, thanks to people like you many more people like me can use Unreal.
Well… no… 
What you have there, is a Pawn (or Character…).
You need a PlayerController, different class (and has a Gamepad as Icon). Just do the mini tut about creating a PC as described…
your cast and rrference set is a bit wrong, too.
After Setting the Reference (the “Set” Node), nothing should follow.
So… remove the Line between the Set and the Delay - But, connect the delay to the CastFailed instead.
You want to hold that loop as long as the cast fails… if it succeeds… you want to set the ref and finish that loop by doing nothing after that.
In your Widget Graph, add an EventConstruct.
In that EventConstruct, add a
GetPlayerController -> CastTo PC_Gameplay -> On Succeed, save the reference as variable in the Widget
And from that reference, you can get the Bool of the Player Controller.
Additional Tipp:
stay away from Tick Events as much as possible. Use them wisely and in the smallest amount possible… cause to many if them can ruin the performance…
F.e. i’m on the adventure of creating a mixture of Diablo, Souls and Keeper-likes… and i have 1 Tivk in my whole Project… that just deals the updating of the Debug HUD…
1 Like
Hello, I’m sorry I didn’t understand your instructions, now everything is correct. I just have a couple of doubts:
-
Why I can’t connect “Event Construct” to “Get” in any way, I can’t find the way, am I missing something?
-
When everything is correct, will my Boolean Variables “magically” appear in the Blueprint Widget?
I can’t stop thanking you once again for the time you are spending so that I can learn how to do this. I can’t imagine how absurdly complex and complicated it must be to make a Diablo type game with how much it’s costing me to make a simple visual novel.
Best regards and thanks !
You really should watch some YT Beginner Videos to understand Blueprint variables and References ^^"
But… to finish up this… before you start looking for Videos…
In your Level BP… to get a valid Player Controller Reference… you do it like this:
In Your Widget… Create a new variable of Type of your PlayerController:

Make this Variable ExposedOnSpawn and InstanceEditable:

Now… when you Create your Widget, you can pass in your PlayerController Reference:

Important here:
(1) is your PlayerController Reference. You can get it via GetPlayerController and then cast to your PC Class (like in the Level BP). Or, if you spawn the Widget inside your PC Class, just use “Self” (last one is recommended… spawn and store Widgets via PlayerController!)
(2) Is the reference to your Widget. Store that as variable to call functions, Events and get/Set variables in your Widget.
If you can´t set your SelfController on CreateWidget… cause of what reason ever…
Do it like this in your Event Construct:
So… and now… go and watch some Videos about Blueprint References, variables and best: Interfaces!
1 Like
IT WORKS!!! Thank you so much for your invaluable help
.
At the same time thank you very much for the tips like staying away from Tick Events to improve the performance, for my side I have limited the frames to 24 (since being a visual novel I don’t need more) to improve the performance even more.
I take your good advice to watch some videos about Blueprint References, variables and Interfaces; don’t think I haven’t done it already, but they are many types of nodes and when I think I understand enough about the logic they follow I discover (when I try by myself) that it turns out to be more complicated (for me) than I thought.
I found this page that looks good
Thanks again for everything, I hope your answers will help other newbies like me
.
P.S. I hope you are doing very well with the game you are developing!
P.S. of the P.S.: I’ve never seen nodes looking like that in Unreal 5, is it some kind of aesthetic plugin?
1 Like
yes
NodeGraphAssistant for the squared Lines and some really useful Quality of Life functions in the handling of Blueprint Graphs…
and FlatNodes to get rid of the Round borders and 3Dish look…
1 Like