Skip to main content

Offline Mode

"Offline" means two different things in MCE, and mixing them up is how a team ends up debugging a connection that was never meant to exist.

What it isWho it is for
No online layerThe engine is built without the MCE_ONLINE scripting define. The Nakama layer is not compiled in at all.Every single‑player game. This is the default.
Offline fallbackThe online layer IS compiled in, but there is no server answering right now.An online game whose server is down, or a player with no connection.

A single‑player game needs nothing from this page: without MCE_ONLINE there is no connection to lose. The rest of the page is about the second column.

What puts a session into offline​

NakamaManager has one state machine, and four different situations put it in Offline:

SituationWhat happens
No OnlineConfig asset foundOffline, with No OnlineConfig found. Online features disabled. in the log
EnableOnline is off in the configOffline, and the connect call returns false instead of throwing
The connection fails and AllowOfflineFallback is on (the default)Offline, with Falling back to offline mode. in the log
The connection fails and AllowOfflineFallback is offFailed — a distinct state, for a game that would rather stop than run half‑online

That last row is the whole reason the flag exists. A game where progress must be authoritative — a competitive ladder, a shared economy — is better off refusing to start than letting the player play a session the server will never accept. A game where the online part is a bonus wants the opposite. The flag is in the OnlineConfig asset, next to EnableOnline.

IsOffline is true for Offline and for Disconnected, because code that asks "can I send this?" wants the same answer in both.

What still works​

Every online service is constructable with no manager at all. That is not a side effect, it is the contract: the services are built at startup, before anyone knows whether a server will answer, and a service that threw in its constructor would take the game down with it.

So WorldSyncService, BattleMatchmaker, SpectatorService, RaidBattleService, FriendService, TradeService, GTLService, WalletService, ShopService, CloudSaveService, HousingService and ChannelManager all exist in an offline session. What they do not do is talk to anything: a call that needs the server reports failure instead of blocking. CloudSaveService.HasCloudSave is false, and the local save system — the same one a single‑player game uses — keeps the game going.

The edit‑mode test OnlineServices_HandleOfflineMode is what holds that line: it constructs all twelve with a null manager and fails if any of them throws.

Going back online​

DisconnectAsync returns immediately when the state is already Disconnected or Offline, so calling it on an offline session is safe and cheap. A reconnect is an ordinary connect call; nothing has to be torn down first.

What this page does not show​

There is no screenshot here yet of a session playing in offline fallback. The states, the flag and the twelve services are read from the code and covered by the test named above; the captured run with the server deliberately stopped is still pending.