How do public booleans work


Hello, I’m really confused with public booleans, I had barely started learning unity when I switched to unreal and all I want to do is check a boolean in my menu UI blueprint from my menu level blueprint, I’ve looked it up and most answers are for different kinds of blueprints using cast to and referencing player objects, but I get errors when I do that. The only other solution included watching a 2 hour video essay about blueprint communication which I don’t want to do.

Can someone explain what cast to does and how to fix this like im stupid, cause i am.

First image is the UI blueprint that the boolean is located in
Second image is the Level blueprint that I want to check the boolean from.

1 Like

This sounds very much like something I’d say and / or write.


This menu widget you’re trying to access:

Where is it created? Where the arrow is pointing? Could it be the Add to Viewport node hiding at the edge?


what cast to does

It’s a test + conversion. Here, you take an object reference of any type and test if it’s the object type that you want (you’re testing if the object you did not provide is a menu widget). If the test succeeds, the engine will allow you to use this object (as Menu) as if it was the object of the type you wanted.

This node in the middle is also casting:

image

We’re testing if the letter Q is an integer and then attempt to convert and use it as a digit. As you can imagine, this will not compute well. In both cases you need a value to test.

So, where is the menu widget?


I think I understand, theres a full ss of the level blueprint, I’m not sure what Menu would inherit from though, MainMenu is attached to LevelSequenceActor but connecting that didn’t do anything.

Right click the Return Value pin of the create widget node and Promote to Variable. Use it to access to bool. There’s no need to cast.

Im not sure how I’m supposed to use it to access the boolean, I can do that but I don’t know where to go from there

image
From what I’ve been reading I’m under the impression that the boolean should be listed under the MainMenu variable, is it not working correctly or am I completely wrong?

It would need to look like so:

The white execution wires must be connected for the data to flow.


However, you never explained what we’re doing and the script in FlipFlop’s B will never execute:


Assuming you’re trying to press a button in the widget to play a sequence in the Level Blueprint:

The above is an example of an Event Dispatcher, this one is built into the button. Here, the button subscribes (bind) to a Custom Event and will execute said event when clicked. You can create it easier like this:

There will be no need for a boolean, any script in the widget or casting, and the widget references variable is optional, too. Hope I’m getting close!