Skip to content

fix: NetworkTransform was not ending extrapolation for some states. [MTT-4521] #2170

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
merged 38 commits into from
Sep 8, 2022

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Aug 30, 2022

The most recent NetworkTransform update had a regression bug that exposed some potential timing issues with ending extrapolation. This resolves the issue by migrating the "stop extrapolating the last state" logic over to the non-authoritative side. This also fixes an issue where axis marked to be synchronized would not continue to interpolate/extrapolate even if the next state did not include deltas. This also helped resolve the over-all extrapolation issue where axial deltas would start to interpolate towards the target value but could potentially be stopped if another NetworkTransformState was received before the current state was ended.

MTT-4521

Changelog

  • Fixed: Issue where NetworkTransform was not ending extrapolation for the previous state causing non-authoritative instances to become out of synch.
  • Fixed: Issue where NetworkTransform was not continuing to interpolate for the remainder of the associated tick period.
  • Fixed: Issue during NetworkTransform.OnNetworkSpawn for non-authoritative instances where it was initializing interpolators with the replicated network state which now only contains the transform deltas that occurred during a network tick and not the entire transform state. (WIP-Pending scale synchronization during NetworkObject serialization)
  • Fixed: Issue where NetworkTransform was not honoring the InLocalSpace property on the authority side during OnNetworkSpawn.

Testing and Documentation

  • Includes integration tests:
    • NetworkTransformMultipleChangesOverTime
    • NetworkTransformParentedLocalSpaceTest
  • No documentation changes or additions were necessary.

working version that needs clean up
Some touch ups and adjustments to the fix for the extrapolation issue.
adding some minor comments
Added comments and renamed a property.
some code clean up and additional comments
MTT-4521
updating changelog file
@NoelStephensUnity NoelStephensUnity changed the title fix: NetworkTransform was not ending extrapolation for some states. fix: NetworkTransform was not ending extrapolation for some states. [MTT-4521] Aug 30, 2022
MTT-4521
Renamed StopExtrapolatingLastState to TryToStopExtrapolatingLastState.

Added/adjusted comments.
Applying suggested changes.
removing some changes I made while testing out extrapolating past the target.
adjusted comment.
adjusted comment for clarity purposes.
Adding some of the tests.  Still WIP, but wanted to see how the first completed test fairs in Yamato and on consoles.
removing unused namespace.
Added a form of tick synchronization prior to making changes to the authoritative transform state.
adjusting comments.
- Added NetworkTransformParentedLocalSpaceTests with associated helper methods, components, and properties.
- Added an "Authority" suffixe to the Authority enums for better clarity when looking at the tests within test runner.
- Updated/added additional comments
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review August 31, 2022 19:09
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner August 31, 2022 19:09
Copy link
Contributor

@JesseOlmer JesseOlmer left a comment

Choose a reason for hiding this comment

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

I've approved, but honestly, NetworkTransform is still really hard for me to follow all of the authoritative/non-authoritative/local/interpolator/tick fields and their relationships through this code, so I'm mostly going on faith & our manual test verification here.

Making NetworkTransformParentedLocalSpaceTests singular (NetworkTransformParentedLocalSpaceTest)
adding remarks around comments
splitting the comment into a summary with remarks.
updating a comment on the UpdateAuthoritativeState method.
Copy paste issue.
(need to revisit tests to see why they didn't catch this)
NoelStephensUnity and others added 15 commits August 31, 2022 15:47
z component
using the eurlerAngles... that section of code was a mess!
(sorry!)
Just adding some parenthesis per Kitty's suggestion.
Updated ApplyAuthoritativeState so that it is less complicated to follow.
Fixed another issue discovered where the replicated network state values were being used for resetting interpolators during spawn initialization.  Since the replicated network state only has the most recent deltas at the time the NetworkObject is serialized, this would cause "seemingly random" late joining issues.
This validates the issue with the more recent updates that revealed the network state only having the most recent deltas and not the full transform state.  This resulted in various "seemingly" random late join transform synchronization issues (specifically the scale that is not being synchronized when spawning NetworkObjects).
removed the unnecessary else if (useInterpolatedValue) condition and re-organized it such that it checks to see if it needs to apply interpolation or just depends upon the state to apply the values directly.

Added additional comments about this area of the code and future improvements.
Removing unclamped slerp and lerp due to a few timing related issues.  These issues should be solved before re-enabling any form of unclamped lerping/slerping with BufferedLinearInterpolator.

Added additional comments in some areas to be investigated for a potential fix.
temporarily disabling two editor based interpolator extrapolation based tests until I can refactor them to not take extrapolated values into consideration.
removing debug code used to verify NetworkTransform is not the only thing within NGO that fails when dropping packets (most likely to occur 20-30% drop rate).
Make sure to initialize based on whether it is set to world or local space.
When authority is applying the current position and rotation during OnNetworkSpawn, use the appropriate local vs world space values.
Adding another fix to the change log
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) September 8, 2022 15:19
@NoelStephensUnity NoelStephensUnity merged commit 20ad052 into develop Sep 8, 2022
@NoelStephensUnity NoelStephensUnity deleted the fix/networktransform-extrapolation branch September 8, 2022 15:46
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…MTT-4521] (Unity-Technologies#2170)

* update

working version that needs clean up

* update

Some touch ups and adjustments to the fix for the extrapolation issue.

* style

adding some minor comments

* update

Added comments and renamed a property.

* update

some code clean up and additional comments

* update

MTT-4521
updating changelog file

* update

MTT-4521
Renamed StopExtrapolatingLastState to TryToStopExtrapolatingLastState.

Added/adjusted comments.

* update

Applying suggested changes.

* update

removing some changes I made while testing out extrapolating past the target.
adjusted comment.

* style

adjusted comment for clarity purposes.

* test

Adding some of the tests.  Still WIP, but wanted to see how the first completed test fairs in Yamato and on consoles.

* style

removing unused namespace.

* test update

Added a form of tick synchronization prior to making changes to the authoritative transform state.

* style

adjusting comments.

* test

- Added NetworkTransformParentedLocalSpaceTests with associated helper methods, components, and properties.
- Added an "Authority" suffixe to the Authority enums for better clarity when looking at the tests within test runner.
- Updated/added additional comments

* style

Making NetworkTransformParentedLocalSpaceTests singular (NetworkTransformParentedLocalSpaceTest)

* style

adding remarks around comments

* style

splitting the comment into a summary with remarks.

* style

updating a comment on the UpdateAuthoritativeState method.

* fix

Copy paste issue.
(need to revisit tests to see why they didn't catch this)

* fix

z component

* fix

using the eurlerAngles... that section of code was a mess!
(sorry!)

* update

Just adding some parenthesis per Kitty's suggestion.

* update and fix

Updated ApplyAuthoritativeState so that it is less complicated to follow.
Fixed another issue discovered where the replicated network state values were being used for resetting interpolators during spawn initialization.  Since the replicated network state only has the most recent deltas at the time the NetworkObject is serialized, this would cause "seemingly random" late joining issues.

* test update

This validates the issue with the more recent updates that revealed the network state only having the most recent deltas and not the full transform state.  This resulted in various "seemingly" random late join transform synchronization issues (specifically the scale that is not being synchronized when spawning NetworkObjects).

* update

removed the unnecessary else if (useInterpolatedValue) condition and re-organized it such that it checks to see if it needs to apply interpolation or just depends upon the state to apply the values directly.

Added additional comments about this area of the code and future improvements.

* fix

Removing unclamped slerp and lerp due to a few timing related issues.  These issues should be solved before re-enabling any form of unclamped lerping/slerping with BufferedLinearInterpolator.

Added additional comments in some areas to be investigated for a potential fix.

* fix

temporarily disabling two editor based interpolator extrapolation based tests until I can refactor them to not take extrapolated values into consideration.

* fix

removing debug code used to verify NetworkTransform is not the only thing within NGO that fails when dropping packets (most likely to occur 20-30% drop rate).

* fix

Make sure to initialize based on whether it is set to world or local space.

* fix

When authority is applying the current position and rotation during OnNetworkSpawn, use the appropriate local vs world space values.

* update

Adding another fix to the change log

Co-authored-by: ashwini <36935028+ashwinimurt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants