Links
📶

Network Synchronisation

Integrate the Network Synchronisation
You can synchronise the animations on your netcode with our server agnostic solution.

Network Implementation

On Remote Player Join

Once a remote peer connect in your same room or is already connected in the room, you can register them by giving in argument their peer network IDs, and their animator:
KinetixCore.Network.RegisterRemotePeerAnimator(string _RemotePeerUUID,
Animator _Animator);
Then get and store the automatically added KinetixCharacterComponent
this.kcc = KinetixCore.Network.GetRemoteKCC(Id.ToString());

On Remote Player Leave

Once a remote peer disconnect in your same room, you can unregister them by giving in argument their peer network ID.
KinetixCore.Network.UnregisterRemotePeer(string _RemotePeerUUID);

On Local Player Leave

Once a the local peer disconnect of the room, you can unregister all remote peers.
KinetixCore.Network.UnregisterAllRemotePeers();

Getting the pose

byte[] currentPose = kcc.GetSerializedPose();
byte[] previousPose = null;
​
// If no emote is playing, GetPose() will return null
// So, when the emote is finished we will start to receive null again
if (currentPose != null || previousPose != null)
{
// Send the pose as a byte array on the network
// YOUR SPECIFIC NETWORK CODE HERE
// Affect previousPose
previousPose = currentPose
}

Applying the pose

// Called on remote peers, apply the pose sent by local player
private void ApplyPose()
{
// The KCC relies on timestamps to apply the poses reliably
timer = DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
// Ask KinetixCharacterComponent to apply the pose on remote peer
kcc.ApplySerializedPose(bytePose, timer);
}

NetworkConfiguration

You can define your own configuration, allowing you to change:
  • MaxWaitTimeBeforeEmoteExpiration the time to wait for additional frames in case of packet loss or extreme lag
  • TargetFrameCacheCount the number of frame cached before launching the emote
  • SendLocalPosition if you want to allow "stretching" emotes where the characters have their member dislocated. By default only the Hips bone's position is sent (movements on the root of the avatar). Enabling this option will cost more resources.
  • SendLocalScale if you want to allow scale deformation on emotes. Enabling this option will cost more resources.
You can set the configuration using this method:
KinetixCore.Network.SetConfiguration(new KinetixNetworkConfiguration {
MaxWaitTimeBeforeEmoteExpiration = 2f,
TargetFrameCacheCount = 10,
SendLocalPosition = false,
SendLocalScale = false,
});

Integration's exemple :