Skip to main content

Session Player Manager

1. Overview

The SessionPlayerManager is a core networked component responsible for instantiating and managing the lifecycle of player representations within a HoloMIT session. It coordinates the spawning of local and remote player prefabs and assigns them to specific spawn locations based on Master authority.


2. Component Configuration

Figure 1: Configuration of the SessionPlayerManager component in the Unity Inspector.

2.1. Player Rig Prefabs

  • Player Prefab: The default prefab instantiated for players (typically the local user, or remote users if custom prefabs are disabled).
  • Use More Prefabs (bool): If enabled, allows specifying a different prefab exclusively for remote users.
  • Player Prefab Remote: The specific prefab used for remote users when Use More Prefabs is active.

2.2. Spawn Locations

  • Auto Spawn On Location (bool): If true, the session Master will automatically place joining players into the first available PlayerLocation from the configured list.
  • Player Locations (List): A list of PlayerLocation references defining the available spawn points in the scene.
  • Non Players Location (Transform): A specific area (usually out of sight) where spectators or non-player entities are spawned.

2.3. Self Rendering

  • Do Not Render Self User (bool): If enabled, the local player will not consume its own volumetric representation. This is useful for passthrough experiences or to save bandwidth and processing power locally while still consuming remote users.

3. Network Architecture & Authority

3.1. Master / Client Architecture

The SessionPlayerManager relies heavily on a Master-Client architecture. The first user to enter the session is designated as the Session Master.

  • Master Responsibilities: Assigns players to spawn locations, processes location change requests from clients, and broadcasts PlayerLocationData to keep everyone synchronized.
  • Client Responsibilities: Clients send a PlayerLocationDataRequest upon joining to get the current state. If a client wants to move to a different spawn point, they send a PlayerLocationChangeRequest to the Master.

3.2. Event Management Integration

The manager uses the EventManagerController to transmit custom network messages:

  • PlayerLocationData: Broadcast by the master to sync positions.
  • PlayerLocationChangeRequest: Sent by clients to request a location swap.
  • NetworkMasterID: Broadcast by the master to inform everyone of the current master ID.

4. Player Instantiation Workflow

When a player joins (OnPlayerJoinedSessionEvent), the manager performs the following workflow:

  1. Determines if the user is local or remote.
  2. Selects and instantiates the appropriate prefab (PlayerPrefab or PlayerPrefabRemote).
  3. Attaches the NetworkPlayer component and assigns the correct Player ID.
  4. Uses the UserRepresentationType to categorize the user as a Player or Spectator.
  5. Invokes the RepresentationHandlerRegistry to set up visual and audio streams correctly based on their representation type (e.g., PC, VR, Cameraman, Voice).

5. Public API Reference

  • public void RequestLocationChange(string locationNetworkId)
    • locationNetworkId: The unique Network ID (GUID) of the target PlayerLocation the user wishes to move to. Allows a player to request a move to a different spawn location. If the local user is the Master, the move happens immediately; otherwise, a network request is sent to the Master for approval.
  • public string GetSelfPlayerId() Returns the unique string ID of the local player.