Setting a ForEachLoop to return a certain value if only one variable out of an array is true

Make it into a function and have the function return true Boolean if it is true and return false on Completed otherwise.

Note that using GetAllActorsOfClass on Event Tick in a Blueprint is probably one of the worst things you can do to slow down the performance. Whatever it is you are checking for most likely don’t need to happen on tick even if you think it does and if the results don’t change very often you should store them in a variable instead of getting them all the time.

You would do it like this:

The ForEachLoopWithBreak lets you stop the loop on its tracks.

So if any returns true, the loops stops with the bool set as true. otherwise the loop will run until the end with the bool set as false.

In any case, once the loop stops, you’ll have the return bool to branch off from.

1 Like

I like your method!

it’s very elegant.

This one is a real brainbuster for me, but I need to figure out a way to determine if just one of the desired variable from the GetAllActorsOfClass node returns true, then set the boolean value for the entire loop to be true. Is there some magic node to do this BS? Thanks.

Yeah I see where you’re going with that. I’m using getallactors on event tick but only every 5 seconds, so it doesn’t have a huge performance hit.

That worked like a hot-■■■■ thank you so much! I woulda never gotten that on my own.