Nonon Zone LoginManager

Prefabs and Scripts

The LoginManager and LoginManager UI is handling the start process for deployed builds. Just add the Script to your Login Manager UI or just use the LoginManager Prefab of the Asset.

In the Start Scene Client add the name of the first Scene the client will load after the LoginScene and is successfully logged in.

For the transfer of the LoginData to the new Scene there is a prefab called ClientPlayerData. This prefab or Script has to be added to the scene, that the mechanism is working correctly.

When the client is started, the arguments given to the command line are filled into the Client Player Data, which is not destroyed after loading new scenes

Mode: The mode can be SERVER, HOST or CLIENT
Loading Scene: The loading scene has to be the precise name of the scene that is loaded after login. The Scene has also to be registered in the build settings that it can be loaded.
Player Name: The player name is taken from the Login UI
Join Code: This is used for the relay service and is taken from the DEV HUD (Relay is just implemented as runnable first demo)

In the actual scene there needs to be a GameController active, that handles the loading of the scenes, persistence and player spawning. On top of the simple GameController script, there has to be the NononZonePersister Script to be active, otherwise the Server traversal with weapons does not work.

Command Lind Starting Parameter

The following syntax can be used:

ExecutableName -Mode [SERVER|CLIENT|HOST] -Scene [NameofScene]

for example to start two servers and one client:
Nonon_Multiplayer -Mode SERVER -Scene MultiplayerBlablaZone
Nonon_Multiplayer -Mode SERVER -Scene MultiplayerPlaygroundZone
Nonon_Multiplayer -Mode CLIENT -Scene LoginScene

Login Process

Starting the server….

When the executable is started with the command line args for the server, the scene is loaded immediately. As this is happening somewhere on the server, there is no UI to choose anything from.

Starting the client….

When the executable is started with the command line args for the client the LoginScene has to be the first scene in the executable. The scene which is loaded is taken from the LoginManagerUI” script and the field “startSceneClient” after pressing Login Button. The player name is transferred into the Client Player Data and the scene is loaded. The password is ignored for the time being.

When the scene is loaded with GameController present….

In the new scene there has to be a GameController Component in the Scene. The Game Controller does the following:

  1. OnSceneLoaded: The Gamecontroller looks in which mode the game is running and is starting either Server, Client or Host.
    If the game is in Server Mode, an approval callback is registered and the server is started.
    If the game is in Client Mode, the Player name filled into the Connection Data and the client is started. If it is starting with Relay enabled, the JoinCode is set. (You can add the Login token at this place if you have a valid check for username/password)
    If the game is in Host Mode, the Relay is setup, the approval callback is registered and the player name is filled into the Connection Data and the Host is started.
  2. ApprovalCheck: The Approval callback method is called when a client is connecting to a server or to a host. In this callback, the player name is taken out of the connection data and filled into the ServerPlayerData object. Then the approval is sent back as true. (Here you could check any token that is delivered)
  3. NetworkOnClientConnected: When the approval is true, the callback method NetworkOnClientConnected is called. In this method the player is actually spawned by the server. In this method the following happens:
    1. The player prefab registered in the GameController is spawned.
    2. The player name is read from the ServerPlayerData and set on the spawned player
    3. If there is player data (weapons, thruster, health) persisted, it is loaded and set on the player (this is important if we want to jump between different servers)
    4. It starts an appearing effect and sets the spawning position of the Player

Categories: Multiplayer


Leave a Reply

Avatar placeholder