Network Player Synchronization
1. Overview
Synchronization of player avatars in HoloMIT is divided into two parts: the overall player position (NetworkPlayerTransform) and the detailed orientation of the head and hands (NetworkPlayer). This ensures that while the player moves through the space, their virtual presence (VR avatar) remains accurate and smooth for other participants.
2. NetworkPlayerTransform
This component synchronizes the root Transform (Position, Rotation, and Scale) of the player GameObject.
2.1. Key Properties
- Update Frequency (float): Default is 15 Hz. High enough for smooth locomotion while maintaining network efficiency.
- Interpolate Updates (bool): Default is
true. Essential for VR to avoid seeing other players "teleporting" or jittering.
2.2. Logic Flow
- Local Player: If
isLocalPlayeris true, the component broadcasts its transform at the definedUpdateFrequency. - Remote Player: If
isLocalPlayeris false, it listens for updates from the specificPlayerIdand applies them using Linear Interpolation (Lerp) for position and Spherical Linear Interpolation (Slerp) for rotation.
3. NetworkPlayer (Avatar Data)
The NetworkPlayer component is the central hub for the player's presence. It handles the synchronization of the VR tracking data (Head and Hands).
3.1. Synchronized Elements
The component sends a NetworkPlayerData message containing:
- Head Position & Orientation
- Left Hand Position & Orientation
- Right Hand Position & Orientation
3.2. Configuration
Figure 1: NetworkPlayer setup showing references to Head and Hand transforms.
- Send Rate (int): The number of times per second tracking data is broadcast (default: 10).
- Tracked Pose Drivers: These are automatically enabled for the local player and disabled for remote players to prevent local tracking from overriding network data.
4. How it Works
- When a player joins, their prefab is instantiated.
SetIsLocalPlayer(true)is called for the player who "owns" the avatar.- Every
1/SendRateseconds, the local tracking data is packaged and sent viaEventManagerController.Instance.SendSceneEventToAll. - Remote clients receiving this data identify the target player by
PlayerIdand update the corresponding transforms using interpolation.
5. Public API Reference
public bool IsLocalPlayer: Returns whether the current instance is controlled by the local user.public void SetIsLocalPlayer(bool _local): Configures the instance as local or remote, toggling pose drivers and sync logic.public HandInteractionManager GetHandInteractionManager(Handedness): Returns the interaction manager attached to the specified hand transform.
6. Common Pitfalls
- Parenting: Tracking data (Head/Hands) is often synchronized in Local Space relative to the player root. Ensure the hierarchy in the player prefab matches between the local and remote representations.
- Update Frequency vs. Send Rate:
NetworkPlayerTransform(locomotion) andNetworkPlayer(avatar tracking) can have different frequencies. Locomotion usually requires fewer updates than fast hand movements.