Sync per-pose index and locomotion state across the network

Add PlayerAnimationSync NetworkBehaviour with owner-authoritative
NetworkVariables for pose index and locomotion category (idle/walk/run/fall).
Remote avatars switch their PlayerPoseController into network-controlled mode,
skipping local input, sprint reset, capsule resize and camera framing, and
take pose index plus locomotion externally. Disable pose persistence on
network-driven remotes so foreign avatars can't overwrite the local save.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-27 14:44:11 +02:00
1 parent 4fa443f630
commit 7f2f4e5999
5 files changed
+186 -29

No files matched your search

@@ -62,7 +62,9 @@ public partial class PlayerPoseController
/// <summary>Writes the current pose index to disk.</summary>
public void SavePoseState()
{
if (!persistPose) return;
// A network-driven remote avatar shares the local "Player(Clone)" save key with the owned avatar;
// persisting it would clobber the local player's saved pose with a replicated one.
if (_networkControlled || !persistPose) return;
try
{
@@ -79,7 +81,9 @@ public partial class PlayerPoseController
/// <summary>Restores the saved pose index, or does nothing if there is no save.</summary>
private void RestorePoseState()
{
if (!persistPose) return;
// Skip on a network-driven remote avatar: its pose is replicated from the owner, and reading the
// local save would briefly show the wrong pose before the first network update arrives.
if (_networkControlled || !persistPose) return;
var state = LoadPoseState();
if (state == null) return;