Login and Authentication Flow
Scene sequence
- LoginScene โ the player enters credentials.
LoginManagerchecksRodNetworkManager.PendingChangeCharacteron load; if it is set, the login UI is skipped and the player is forwarded directly to CharacterSelect, preserving the authenticated session. - 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). - HUB / zone โ
RodNetworkManagerspawns 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:
| Field | Type | Notes |
|---|---|---|
username | string | Authenticated account name. |
classIndex | int | Class selected by the player (0โ5). |
spawnX, spawnY, spawnZ | float | Logout position read from the DB character record. |
zone | string | Logout zone from DB, normalized via SceneNames.NormalizeZone(). Always a valid zone name. |
hasSavedPosition | bool | false for fresh characters whose DB position matches 0/0/0 or the legacy default 0/2/0. |
fromDB | bool | false in dev mode; stats and position come from CreatePlayerMessage instead of the DB. |
gmAllowed | bool | Whether the account has GM access. |
gmLevel | int | GM 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.Tokenis set to the new token.AuthManager.CharacterIdis set toid.
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():
LoadingScreen.Show("Character Selection")(client builds only; guarded by#if !UNITY_SERVER).RodNetworkManager.PendingChangeCharacteris set totrue.- If the client is connected,
ReturnToCharacterSelect()sends aGracefulDisconnectMessageto the server, which callsRodPositionSaver.SaveBeforeDisconnect()to write the final position before disconnecting. A 6-second timeout forces a disconnect if the server does not respond. - After disconnect, Mirror loads
LoginSceneviaofflineScene.LoginManagerreadsPendingChangeCharacter, 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():
LoadingScreen.Show("Saving Character")(client builds only).- If the client is connected, sends a
GracefulDisconnectMessage. The server saves the position and disconnects the client. RodNetworkManager.OnClientDisconnect()callsApplication.Quit()(or stops play mode in the editor) after the disconnect is confirmed.- 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