Download

Implementing a lobby system and transfering players

Hello,

I want to know how to transfer players from a game lobby to the game keeping their settings saved.

I can create a gamelobby using slate and another game mode. But, where do I save the lobby information?
As far as i know, the game state changes when when the gamemode changes?

Other than that, there are 2 ways I can think off. PlayerState or GameInstance.

I am not sure if playerstate is appropriate for this task or not.
And if using GameInstance? How do I know which player is which after the new game has loaded. Any help?

GameInstances is the one to use I believe, it stores persistent data between levels from what I remember. You can then pass that data to the GameMode in the game level.

The PlayerState data changes when going from 1 level to another?
But I think I also need to store the ip address of the player and later confirm it or are there better ways to know which player is which?.

E.g. I have a structure having the following variables

  1. Ip Address
  2. Player Name
  3. Player Character(If my team is a class based game)
  4. Team(If my team has more than 1 teams)

I have a array of this structure in my game. Then in the lobby, I store all these data in the array and later match these data while the game starts and spawn players accordingly.

I want to know if this is how it is done or are their better ways to do it?

Yes, PlayerState is unique to the level so you can’t store persistent data there if you want to transfer between levels.

There should be a fairly standard approach to doing this, but you have to go a level deeper than PlayerControllers. Looking at ShooterGame, it goes up a few levels to access the ‘UPlayer’ class, which is about as physical as it gets when trying to get a reference to a specific player. UPlayer’s should be persistent once they’re connected to a server whether in-world or not. (I think, worth reading up on that though!)

Thing is, you don’t want to be modifying the UPlayer class, but you might want to be storing a reference to it in the GameInstance, along with that players variables such as Team Number, Player Name etc, then read from that in the GameMode of your new level.

It’s certainly not impossible. In fact, take a look at Unreal Tournaments source code, they have exactly this kind of stuff implemented I believe.

Thank you… I didn’t knew about the UPlayer class. That is what I was looking for.

Also another a bit unrealted question. I am using 4.6.1 UE4 what version of UE4 do I need to run the UT$?