Check if all elements in an array are true

Im trying to make a last team standing gamemode problem is I need it to check if all players on one team are dead but from all I see we have for each loop and for loop but it returns true if only one element becomes true for now I just want to be able to create the logic to check if all elements in an array are true if yes then return true

please don’t tell me just do it in c++ unless c++ is the only option then I will do that

Just use the Contains Item node

Loop it to make sure that they are the only ones. If any return false, well, there you have it. Pretty much, depending on the number of teams, you will just be checking each of them.

Thank you I will try that

So that didnt work for it is returning true the second one player is dead it returns true I need it so if lets say their are 5 players I need it so if all 5 players die then return true if only 4/5 players died return flase

When you say use an and bool is am I connecting player 1 player 2 player 3 player 4 and player 5 in the 5 pins of the And node

So…you would add to array “PlayerDead” Player One, Player Two, Player Three, etc… then use an AND bool to make sure that all 5 players are dead (all return true)…

So five contains, each looking for 5 unique players. Those players are only added to the array when dead. And when all 5 players are returning true…well, you get the results you want.

Yes you will be connecting those pins in the AND node and then the Branch would be true or false. False would redo it until they are all true, and then you can do whatever it is that you originally intended.

This is really late, but for anyone curious for a quick workaround, I used a ‘Contains item’ node to check for any ‘false’ bools in the array, then attached it to a branch like so:

If false, then all the ‘buttons’ in this scenario are activated.

1 Like