Handling Player Joins Mid-Game

Hello everyone,

I’m relatively new to Verse and coding so I’d appreciate any guidance.

I’m working on a fighting map with 2 teams and 16 custom rounds, all managed through Verse. Instead of using UEFN’s built-in round system, I’m running all 16 custom rounds within a single UEFN round.(UEFN built-in rounds are too slow)

Here’s an overview of the game flow:

  1. Game Start Area - all players spawn here in the begining and end of the 16 custom rounds
  2. Team Selection - choose their team
  3. Loadout Voting - vote fot loadout
  4. Start of all 16 rounds - teleport to round area
  5. After all rounds over, players respawn in the Game Start Area to rematch or find a new match

I’m looking for advice on how to handle players who join mid-game.
I’d like to allow players who join before the Team Selection stage to spawn in, while any players joining after this stage should spectate until the current game (all 16 custom rounds) over.
After the final round, all players, including spectators, will respawn in the game start area

Any tips or recommendations would be greatly appreciated!

Thanks in advance!

1 Like

Alright, from personal experience, you shouldn’t put players in spectators during 16 rounds :smiley: (not even 2 rounds imo)
But it depends on the length of the rounds I guess. If the rounds are long and you need to keep that spectate mechanic because the gameplay cannot be designed otherwise, I’d suggest either :

  • Enabling and Disabling Matchmaking dynamically using the Round Settings Device*
  • Giving an alternate thing to do while they wait for the current rounds to end (UI or ig minigame / training…)

It’s a good thing that you did your own round system, so congrats on that :clap:

I’m assuming that you already know the method to trigger things when a player joins the game in Verse, then when a player joins the game (AND gets spawned in), you can just look at the current game state (your previous 1 to 5 bullet points) and act accordingly.

If I understand correctly, basically the only thing you want to do here is send them to spectator if the rounds are currently running right ? (assuming the Game Start Area is indeed the default spawn location, also assuming we don’t show the voting UI for them, that’s how I’d do it)

In order to do so, you’ll want to either kill them when they spawn, or change your island settings Join In Progress parameter to be set on Spectate by default, which means you’re basically reversing the problem (coz you’ll now need to spawn players if the rounds are not currently running)
You could also do like I did in Minigames Box PVP and add a spectate box in the Lobby area that the players need to intentionally go inside if that fits your needs better

On a side note, I’m also curious of what you’re doing if players don’t pick a team :eyes:

First of all thank you for your assistance i really appreciate it :slight_smile:

I didnt know about the option of disabling matchmaking into the island mid game with the round settings device this change a lot.
Yes i am familiar with the PlayerAddedEvent.
Now when a player joins i can just let them spawn. when Join In Progress on Island settings set to spawn and instantly teleport them to the game start/team selection area depends on what stage the game is in. and i can disable matchmaking on team selection timer success. that makes way more sence.

I do have a spectate button i locate it in the Team Selection area when a player press it, it will change his class and start spectate until all rounds are over.

About the players not picking team, i wrote a function that runs when the team selction timer is up, the function will run once for each player that didnt pick a team,count which team has more players and auto asign the player to the smaller team.

I will test everything today and update you with the results. Thank you :slight_smile:

1 Like

Alright, be careful as disabling matchmaking doesn’t mean players can’t join (I think), since loading players will still be loading the map, so be sure to disable matchmaking 1 or 2 minutes before starting your rounds, or handle players who join even after matchmaking gets disabled

Ok ive been trying non stop to make this work.
I successfully disabled matchmaking into the island after a specific time.
Now i want to handle players that already loading in.

I want all players that joins after team selection timer to spectate.

I used this to try and make it work:
Class Selector - Configured to switch players to class 5 and team 4, with respawn on switch enabled
Class Designer - Set with class identifier 5 and a spawn limit of 1
Damage Volume Device - Targeting class 5
Player Spawners - player class 5

The Player Spawners surrounded by the damage volume device.
In the verse code i have a logic variable that switches to false when the team selection timer success. If a player joins after this point, they are assigned to class 5 and immidietly respawn via the class selector and will get eliminated by the damage volume device.

It doesent work. player ignoring and not assigning to the class selector settings.
I don’t know maybe i did something in a wrong way i am still trying to figure it out :weary:

The damage volume event might trigger too soon or smth, what happens if you kill them without switching teams ? Are your players inside the arena supposed to respawn when they die ? Why not send everyone to spectate upon death even without classes assigned ?

If a player joins mid-game, and i eliminating them, it sends them to spectator mode. However, at the end of each custom round, they respawn with the others.

I apologize if my explanation isn’t entirely clear; I’m still in the process of understanding and figuring out the best approach.

In each custom round in my game, player 1 spawn limit. Once they die, they spectate until the round ends. When one team is fully eliminated, I respawn every one elimnated and alive players in a designated mid-round area. None of the players have specific classes assigned.

Given this setup, I want players who join mid-game to stay in spectator mode for the rest of the game, across all rounds. How can I ensure that these late joining players remain in spectator mode and do not respawn until i decide, regardless of what happens in the rounds ?

Get a list of participating players and only respawn those ones ? :person_shrugging:

Hi LAMA. sorry for the late response (I was trying to do what you said and tried other things as well)
I tried so many different methods to try and get the joining players into spectate without affacting the other players and the round system but i failed. one time the players spawn in after 1 round of spectating other time they spawn immediately when joining.
I didnt specified earlier but my island settings spawn limit is set to 1 and im using this workarounds to spawn my players each round:
[Workaround] Spectate a player after calling Respawn() - Development / Programming & Scripting - Epic Developer Community Forums (unrealengine.com)
How do get a list of only the participating players ? and what settings should i choose in the join in progress setting in order to make this work ?
just reminding im new to coding but if you just guide me to the right direction i can investigate by myself so i wont botther you to much :grinning:

I believe you already got a list of participating players if you’re teleporting them out of the lobby, you just need to store that list for later

Hi lama.
I was trying to do as you said but it was to comlicated for me and i didnt want to make any mistakes so i found a different way to do it. but now i have a different problem, the code dosent listen to the EliminatedEvent of the join in progress players how can i listen to thier eliminations ?
I tried writing the EliminatedEvent in the PlayerAddedEvent function but it still dosent work… :weary:

1 Like

The EliminatedEvent is a fort_character event but when PlayerAddedEvent is fired, the fort_character of the player is not available yet, you have to wait for it to be available before listening to the event

ohh ok i think i understand what you mean. when you say fired you mean when the function run ? if so how can i listen to a Eliminated Event of a player that join ? is the fort_character only available when a player is physically spawned ? or it just takes a few seconds ?

1 Like

You have to wait for it to be available, you can try waiting X seconds but it’s not good practice imo, just loop until it’s available :person_shrugging:

1 Like

ok got it. I will try it. thanks again LAMA appreciate the help

i cant do it can you help me out with the code ? i tried creating a function with a loop that run when player is added

    OnPlayerAddedEvent(PlayerAdded:player) : void =
        spawn:
            JoiningPlayerEliminatedEvent(PlayerAdded)

        AllPlayersCounter()
        Class_Selector_Team3.ChangeTeamAndClass(PlayerAdded)

        if( Team_Manage.AllowJoin?):

        else if (not Team_Manage.AllowJoin?):
            spawn:
                SwitchToSpectateMode(PlayerAdded)
 
    JoiningPlayerEliminatedEvent(JoinedPlayer:agent)<suspends>:void=
        loop:
            Sleep(0.0)
            if (FortCharacter := JoinedPlayer.GetFortCharacter[]):
                FortCharacter.EliminatedEvent().Subscribe(PlayerEliminated)

I dont know if im doing it right

More or less, you should just add a break after the PlayerEliminated subscription so that it doesn’t register infinite times

Also if the player leaves before having their fort_character available, it will loop forever here

You could do that instead

JoiningPlayerEliminatedEvent(JoinedPlayer:agent)<suspends>:void=
        race:
            Sleep(60.0) # Max time before giving up
            loop:
                Sleep(0.0)
                if (FortCharacter := JoinedPlayer.GetFortCharacter[]):
                    FortCharacter.EliminatedEvent().Subscribe(PlayerEliminated)
                    break # Will exit the loop, then complete the race, and exit the function

But what if i want the game to keep listening to the join in progress players EliminatedEvent until the game is over, wouldn’t this function break after the player will be eliminated once ? what about the next rounds ? just reminding that each UEFN round its a whole game in my map

Once you subscribe, it keeps listening until the end of the round. Yes, you would need to do this each round.

2 Likes

If the round is a custom round, no need to do it again

1 Like