Skip to content

fix: client not tracking changes to layer weights [MTT-7166] #2674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).

## [Unreleased]
### Added

### Fixed

- Fixed "writing past the end of the buffer" error when calling ResetDirty() on managed network variables that are larger than 256 bytes when serialized.
- Fixed issue where `NetworkAnimator` was not internally tracking changes to layer weights which prevented proper layer weight synchronization back to the original layer weight value. (#2674)
- Fixed "writing past the end of the buffer" error when calling ResetDirty() on managed network variables that are larger than 256 bytes when serialized. (#2670)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching this omission


### Changed

## [1.5.2] - 2023-07-24

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ internal void UpdateAnimationState(AnimationState animationState)
if (m_LayerWeights[animationState.Layer] != animationState.Weight)
{
m_Animator.SetLayerWeight(animationState.Layer, animationState.Weight);
m_LayerWeights[animationState.Layer] = animationState.Weight;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,32 @@ public void WeightUpdateTests([Values] OwnerShipMode ownerShipMode, [Values] Aut
animatorTestHelper = AnimatorTestHelper.ServerSideInstance;
}

var originalWeight = animatorTestHelper.GetLayerWeight(1);

animatorTestHelper.SetLayerWeight(1, 0.75f);
// Wait for all instances to update their weight value for layer 1
success = WaitForConditionOrTimeOutWithTimeTravel(() => AllInstancesSameLayerWeight(ownerShipMode, 1, 0.75f));
Assert.True(success, $"Timed out waiting for all instances to match weight 0.75 on layer 1!");

animatorTestHelper.SetLayerWeight(1, originalWeight);
// Wait for all instances to update their weight value for layer 1
success = WaitForConditionOrTimeOutWithTimeTravel(() => AllInstancesSameLayerWeight(ownerShipMode, 1, originalWeight));
Assert.True(success, $"Timed out waiting for all instances to match weight {originalWeight} on layer 1!");

// Now set the layer weight to 0
animatorTestHelper.SetLayerWeight(1, 0.0f);

// Now late join a client
CreateAndStartNewClientWithTimeTravel();

// Verify the late joined client is synchronized to the changed weight
success = WaitForConditionOrTimeOutWithTimeTravel(() => AllInstancesSameLayerWeight(ownerShipMode, 1, 0.75f));
Assert.True(success, $"[Late-Join] Timed out waiting for all instances to match weight 0.75 on layer 1!");
success = WaitForConditionOrTimeOutWithTimeTravel(() => AllInstancesSameLayerWeight(ownerShipMode, 1, 0.0f));
Assert.True(success, $"[Late-Join] Timed out waiting for all instances to match weight 0 on layer 1!");

animatorTestHelper.SetLayerWeight(1, originalWeight);
// Wait for all instances to update their weight value for layer 1
success = WaitForConditionOrTimeOutWithTimeTravel(() => AllInstancesSameLayerWeight(ownerShipMode, 1, originalWeight));
Assert.True(success, $"Timed out waiting for all instances to match weight {originalWeight} on layer 1!");

AnimatorTestHelper.IsTriggerTest = false;
VerboseDebug($" ------------------ Weight Test [{ownerShipMode}] Stopping ------------------ ");
Expand Down