Unreal Engine multiplayer - set player indexes to specify the player starting pawn

Hello everyone!

I’m currently developing the turn-based multiplayer board game for android with blueprints. I managed to make the basic multiplayer session framework (creating and joining sessions, moving to Lobby Level afterwards, display player names in lobby, updating them, travelling to GameSession level when host presses “Start Game” button etc.). Right now I’m stuck with setting up the players’ starting positions.

What I want: after players join the lobby, every single one of them gets its personal index (from 1 to 4, because this game is for 2-4 players), and after the host starts the game, they travel to the session level and possess a certain pawn, depending on that player index

Four pawns already exist on the session level and were placed manually during level design (These pawns are just a cameras for a player to possess and watch the game board from their perspective).
So the Player1 will start the game inside Camera1 pawn and so on.

I have no idea how and where shall i create that index parameter (editable of course, so the Host can choose which one of the players goes first, second etc.) and how to connect it to the possessing of certain pawn.

Right now i got Core_Menu framework (game mode, game state, player controller, player state) for the main menu with lobby level and Core_Session framework for the game session level.

I suppose that i need to create player index param inside the Core_Menu player state (or player controller) and somehow transfer it inside the Core_Session framework. But only thing i could achieve so far - is to create a variable inside of Menu_PlayerController that becomes overwritten with every new player after EventHandleStartingNewPlayer occurs, so when session starts all of the players possess same camera but not different ones.

Any advices please?

Looking forward to your answers.
Best regards,
Gregory.

During Seamless Travel, a new player state is created for the new level, so the player state from the lobby level will be destroyed, and a new one for the game level will be created
For this reason, you can override Copy Properties in your player state to transfer the index from the lobby player state to the game player state

Copy Properties is called when a player disconnects to save relevant player data to a temporary “inactive” player state while waiting for a reconnection, and during Seamless Travel, precisely for the same reason as you would need it

So if you have set up the indices in the lobby, save them to the player sate, and then copy them over during Copy Properties, and you should have them in your game level

1 Like

Thank you for the answer! Yes, i’ve just found out as well that the “copy properties” in player state is exactly what i need. I already managed to set the seamless travel so this function will be called.
But could you please explain what does “override” means, talking about “Copy Properties”?

I can’t get how to use it properly. At the moment, when i enable seamless and try to servertravel from lobby level to the gameplay level - the cast on the screenshot fails.

Did I understand correctly that I need to create custom Parent Player State and then make two children out of it for both Menu Player State and Game Session Player State?

I tried this method as well, but my CopyProperties event in old Player State continues to return old “Menu” Player State but the new “Session” one…

I’ve set the seamless travel=true inside MenuGameMode and I use Standalone simulation as I am awared of the seamless not working in PIE. Transition map is set as well.

Seamless Travel checkbox in WB_LobbyMenu

Launch properties:
image

Transition map setup with loading screen:


Menu Game Mode defaults:
image

Session Game Mode defaults:

Yes, im dumb. Finally got it worked - on MY last screenshot you can see that I messed up the defaults in new game mode.

Copy params work with two children of parent player state, with seamless travel turned on and in standalone only.

Now I will proceed with working around the player paramrters setup in the lobby level.

Thanks for answer once more!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.