How to make a win screen for 1v1 vs 4v4

First off this is my first game so the way i did things may not be the most efficient but please help if possible. So i have a game im working on similar to worms or territory wars with one team taking turns firing projectiles to the other trying to kill the other side first. I have multiple different UIs set up that pretty much say 1v1? 2v2? Etc. Then if the player selects 2v2 it spawns 4 players total if he selects 4v4 it spawns 8. Pretty simple. My issue is i wanna create the win screen… so in 1v1 its easy if player 1 has 0 health the win screen pops up. But when it comes to 2v2 how can i make it so both players on a team need there health bar down to 0 before the win screen pops up but if you select 1v1 its only the one character. And if its 4v4 then all 4 on one team need to be at 0. Where im stuck is if im in a 4v4 match then if just one player goes down to 0 games over i need all 4 on one team to reach 0 if the game is in 4v4. Do i need to set up a boolean? Hopefully i was detailed enough to provide a idea of what im trying to do. Thank you for any help

When you spawn in the players, set each player to a “Team” array. Each time someone takes damage do a for each loop through the array for that team and check if anyone’s health is over 0. If so, the game goes on. Otherwise, show the win screen for the other team.

In the for each loop you’ll probably need to use a boolean you turn on if someone’s health is over 0. Then on the “completed” output check If that boolean was turned on. If it’s true, the game goes on, if not, it’s over.

Good luck!

Do you have a example of this you can please share? I was able to make a actor array with all 4 of my characters added into it but im brand new to arrays so this is a bit difficult.

If you use your game mode to spawn the players in, then create 4 arrays (Or however many teams you want max). One for each team. Add your players to whichever array they belong to (Team0 through Team3 for 4 teams). You should also tell each player which team they’re on using an int variable for later use.

When a player takes damage, do your normal health subtraction or whatever, including your death events, but before you destroy the actor (if you’re doing that) then call a function on your game mode checking for the remaining players of that team.

And the function on your game mode (can also be a custom event if you prefer) should be something like this:

I’m using a Select and plugging in all the possible teams. You can also keep track of how many teams are dead to finish the entire game with another int that counts up or down whenever a team is declared defeated.

Hopefully that helps. I also used a break on the for each loop so it doesn’t continue to check for more players on the team once it finds one alive. It only needs one alive to keep playing.