Best way to check if all variables are true


What is the best way to check if all variables (from different blueprints) are true so it can call a custom event and play a timeline?

1 Like

If you have that many bools, there might be a better way of doing things. But in the meantime, each BP can report to a central BP they are ready. When they have all reported, the central BP will run the event.



Set a Function, that has a local Variable bool. call it “AllTrue” the Function Return should have a bool, too. Put your local Variable into that with a Get.

From the function Start…
Set the AllTrue to TRUE.
After that, GetAllActorsOfClass. This returns an array of actors. This array only contains Actors… Not class specific. but we will ho there.
So… From the GetAllActorsOfClass, drag a ForEach Loop. The Array input should be the Returned Array.

The Loop outputs one actor of that array at a time. So… Drag a line from the Actor output (the blue) and cast it to your specific Blueprint Class. Link that cast node into the Loop Body Executer.
Ignore the Cast failed for now, just take the unnamed output of the cast note.
Drag a line from the actor output of the cast (blue again) and get the bool you want to ask for if its true. Link that to a branch, that is dragged from thr unnamed output. If the branch is true… You do nothing.
If the branch is false, set your local AllTrue to false!

Now back to the Loop. Link the function Return Node to the Loops Complete Output.
The return should also be linked to the AllTrue Bool, as discribed above.

What is this doing:
When you call that function, it first says, everything is true… But is not giving a return… Before that, it takes all spawned or placed actors of a specific class and askes, if their bool is really true.
If not, and it only needs one boolean to be false, it returns false.

Best, put this function in your PlayerController to make it usable via getPlayerController>Cast

To ask for more classes, set the specific class of the GetAllActorsOfClass to “Actor”.
This will make the function to get ALL Actors in the current Level.
Now back to the loop body. Here you cast for a specific Actor Blueprint.
We now use the Cast failed!
Its nearly a copy and paste the Cast , branch and AllTrue set.
Drag a new cast from the Loop Actor output and cast to another BP Actor. Link that cast to the failed output of the first cast. The bool get, branch and AllTrue set can be copied to the new cast.
Now you check for two different actor BPs in one Loop. And the function will only return true, if all actors have set their bool to true.

1 Like

Works perfectly, thanks!

Can you include a picture please? Im a visual learner.

Also is there not a way to check for like 3 bools true, using a list, like a Struct (or some type of list) where I list my bools?

Strangely enough, AND



Wouldn’t checking all true be an AND rather than an OR?

1 Like

Exactly! :smiley: ( too tired… )

1 Like

Beautiful, ty. The And node is what I was looking for to piece it together.

But is there a way to make a Struct (list?) that I can gather bools from different actors, and list them in a group (struct/list). Then have another Blueprint call that [struct] > which feeds into the And node?

The reason I want a list is it’s easier to keep track of a theme [set] of bools, from different actor Blueprints (and instead of using 5 Cast tos - to get the bools from different actors).

To bypass using “Get all Actors of Class” and Casting you can simply use an Event Dispatcher. Dispatchers can even pass variables.

Essentially you’ll create a “report in” process with the dispatchers.

1 Like