Login and Authentication Flow

Scene sequence

  1. LoginScene โ€” the player enters credentials. LoginManager checks RodNetworkManager.PendingChangeCharacter on load; if it is set, the login UI is skipped and the player is forwarded directly to CharacterSelect, preserving the authenticated session.
  2. CharacterSelect โ€” the player picks a class slot and presses Deploy. The client sends a class selection request; the server responds with { id, class_index, token } binding that slot to a persistent character record (see Heroes and Classes).
  3. HUB / zone โ€” RodNetworkManager spawns the player in their logout zone and at their logout position when conditions are met, or at HUB for fresh characters. See Zones, Scenes and Multi-Zone.

Mirror's offlineScene is set to SceneNames.LoginPath in RodNetworkManager.Awake(). On disconnect, Mirror navigates there automatically.

RodPlayerAuth

RodPlayerAuth is the server-side authentication record attached to each connection after RodNetworkAuthenticator completes. Fields:

FieldTypeNotes
usernamestringAuthenticated account name.
classIndexintClass selected by the player (0โ€“5).
spawnX, spawnY, spawnZfloatLogout position read from the DB character record.
zonestringLogout zone from DB, normalized via SceneNames.NormalizeZone(). Always a valid zone name.
hasSavedPositionboolfalse for fresh characters whose DB position matches 0/0/0 or the legacy default 0/2/0.
fromDBboolfalse in dev mode; stats and position come from CreatePlayerMessage instead of the DB.
gmAllowedboolWhether the account has GM access.
gmLevelintGM privilege level.

Fresh character detection

RodNetworkAuthenticator.IsFreshCharacterPosition(x, y, z) returns true for positions within 0.001 units of 0/0/0 or 0/2/0. These are the DB default values for characters that have never entered the world. Characters with fresh positions have hasSavedPosition = false and always spawn at the HUB zone's configured spawn point.

Character-bound tokens

When the player selects a class on the CharacterSelect screen, the client sends a request to the auth server for that class slot's character record. The server responds with { id, class_index, token }. On success:

  • PlayerPrefs("jwt_token") is updated with the character-bound token.
  • AuthManager.Token is set to the new token.
  • AuthManager.CharacterId is set to id.

If the response is absent, has a mismatched class_index, or has no token, deployment is blocked and the Deploy button resets. Each class slot has its own persistent character record; selecting a different slot issues a different token and character id. See Heroes and Classes for deployment details.

Returning to character select

Pressing Logout or Change Character in the escape menu calls EscMenu.ChangeCharacter():

  1. LoadingScreen.Show("Character Selection") (client builds only; guarded by #if !UNITY_SERVER).
  2. RodNetworkManager.PendingChangeCharacter is set to true.
  3. If the client is connected, ReturnToCharacterSelect() sends a GracefulDisconnectMessage to the server, which calls RodPositionSaver.SaveBeforeDisconnect() to write the final position before disconnecting. A 6-second timeout forces a disconnect if the server does not respond.
  4. After disconnect, Mirror loads LoginScene via offlineScene. LoginManager reads PendingChangeCharacter, skips the login UI, and loads CharacterSelect.

EscMenu.Logout() delegates to ChangeCharacter(). Logout does not clear the authenticated session; it returns the player to class selection with the same account credentials.

Graceful position save on quit

EscMenu.Quit() calls RodNetworkManager.QuitAfterSavingPosition():

  1. LoadingScreen.Show("Saving Character") (client builds only).
  2. If the client is connected, sends a GracefulDisconnectMessage. The server saves the position and disconnects the client.
  3. RodNetworkManager.OnClientDisconnect() calls Application.Quit() (or stops play mode in the editor) after the disconnect is confirmed.
  4. A 6-second timeout triggers a forced disconnect and then quits if the server does not respond.

API dependencies

RodNetworkAuthenticator fetches the character record from the auth server using the player's JWT. VendorPersistenceService and LootPersistenceService also use CROSSWORLDS_GAME_SERVICE_TOKEN (server environment variable) for server-to-server calls; this token is never sent to clients.


Related: Heroes and Classes ยท Zones, Scenes and Multi-Zone ยท GM Console and Tools