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 Prefabsis active.
2.2. Spawn Locations
- Auto Spawn On Location (bool): If true, the session Master will automatically place joining players into the first available
PlayerLocationfrom the configured list. - Player Locations (List): A list of
PlayerLocationreferences 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
PlayerLocationDatato keep everyone synchronized. - Client Responsibilities: Clients send a
PlayerLocationDataRequestupon joining to get the current state. If a client wants to move to a different spawn point, they send aPlayerLocationChangeRequestto 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:
- Determines if the user is local or remote.
- Selects and instantiates the appropriate prefab (
PlayerPrefaborPlayerPrefabRemote). - Attaches the
NetworkPlayercomponent and assigns the correct Player ID. - Uses the
UserRepresentationTypeto categorize the user as a Player or Spectator. - Invokes the
RepresentationHandlerRegistryto 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 targetPlayerLocationthe 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.