Per-player settings

Every setting belongs to someone. That decides where its value is kept and who may change it.

Scope Belongs to Kept in Use for
Device This computer or console The settings file Resolution, quality, volumes, language
Player Each local player Player one: the settings file. Every other player: a file of their own Controls, key bindings, vibration, camera comfort
Save Slot A playthrough The save Difficulty and other choices that belong to one playthrough
Session This run of the game Nowhere Things that should start fresh every launch

Choosing a scope #

Select a setting's asset and set Scope. Automatic uses the setting's usual scope: per player for look sensitivity, invert look, vibration, hold or toggle, field of view, camera shake, head bob and key bindings; per device for everything else. A setting that asks "keep these settings?" (the display mode) is always per device.

Split screen and couch co-op #

Player one is the game-wide settings (SettingsRuntime.Current). When another player joins, give them their own:

// For example from Unity's Player Input Manager, in its Player Joined event.
void OnPlayerJoined(PlayerInput input)
{
    SettingsController settings = SettingsPlayers.Join(input.playerIndex);
    // Read a value for this player.
    float sensitivity = SettingsPlayers.Holder(input.playerIndex, "controls.gamepad-sensitivity")
        .GetFloat("controls.gamepad-sensitivity", 1f);
}

void OnPlayerLeft(PlayerInput input) => SettingsPlayers.Leave(input.playerIndex);
  • A guest has only the per-player settings. Their choices never change player one's or the device's (a guest cannot change the resolution or the master volume).
  • A guest's values are kept in their own file (settings.player2.json beside settings.json) and come back the next time that seat is taken.
  • To let a guest change their settings, bind a settings menu to their controller: menu.Bind(SettingsPlayers.Get(1)). It lists only what belongs to them.
  • A guest's values reach your game through Connect callbacks, ValueApplied and the Get methods. Shipready does not apply them to the device.

Settings that travel with the save #

A Save Slot setting is stored inside the save, through the save contract every Rare Geometry product shares. Saving writes its value; loading a save puts it back and applies it. New Game in the front end sets these settings back to their starting values. From your own code:

SettingsRuntime.Current.ResetScope(SettingScope.SaveSlot);

Session settings #

A Session setting works for the rest of the run and starts from its default at the next launch.

Something unclear or wrong? Tell us · Get help