-
Notifications
You must be signed in to change notification settings - Fork 214
update: NetworkTransform SmoothDampening Updates #1443
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
Open
NoelStephensUnity
wants to merge
7
commits into
develop
Choose a base branch
from
update/networktransform-smooth-dampening-updates
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
update: NetworkTransform SmoothDampening Updates #1443
NoelStephensUnity
wants to merge
7
commits into
develop
from
update/networktransform-smooth-dampening-updates
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoelStephensUnity
added a commit
to Unity-Technologies/com.unity.netcode.gameobjects
that referenced
this pull request
Mar 14, 2025
This PR fixes the issue with double lerping by providing two types of interpolators to select from while also exposing the `MaximumInterpolationTime` for each respective interpolator type. Smooth Dampening is added as an alternative to using lerp for each respective interpolator (position, rotation, and scale). This PR includes a few new additions: - Additional updates to the inspector view which allows for interpolator type selection and if available additional properties associated with the interpolator.     - A new `NetworkTimeSystem.TickLatency` property that provides the average latency of a client. - An new `NetworkTime.FixedDeltaTimeAsDouble` property that returns a `double` version of the `NetworkTime.FixedDeltaTime`. This PR also starts the deprecation process for `BufferedLinearInterpolator<T>.Update(float deltaTime, NetworkTime serverTime)` as this method is only for internal testing purposes. [MTTB-539](https://jira.unity3d.com/browse/MTTB-539) [MTT-11338](https://jira.unity3d.com/browse/MTT-11338) -- Fixing disabled tests fix: #3112 close: #3112 ## Changelog - Added: Interpolator types as an inspector view selection for position, rotation, and scale. - Added: A new smooth dampening interpolator type that provides a nice balance between precision and smoothing results. - Added: `NetworkTimeSystem.TickLatency` property that provides the average latency of a client. - Fixed: Issue where the `MaximumInterpolationTime` could not be modified from within the inspector view or runtime. - Changed: `BufferedLinearInterpolator<T>.Update(float deltaTime, NetworkTime serverTime)` as being deprecated since this method is only used for internal testing purposes. ## Testing and Documentation - Includes integration test updates: - `InterpolatorTests` was updated to changes and two disabled tests were refactored and re-enabled. - `NetworkTransformGeneral` includes additional TestFixture passes using Smooth Dampening. - `NetworktTransformTests` includes additional TestFixture passes using Smooth Dampening. - `NestedNetworkTransformTests` includes additional TestFixture passes using Smooth Dampening. - Includes updates and additions to public documentation ([PR-1443](Unity-Technologies/com.unity.multiplayer.docs#1443)) <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. -->
Just lemme know when you want me to look at this 👍 |
…tps://github.com/Unity-Technologies/com.unity.multiplayer.docs into update/networktransform-smooth-dampening-updates
NoelStephensUnity
added a commit
to Unity-Technologies/com.unity.netcode.gameobjects
that referenced
this pull request
Apr 3, 2025
…#3355) After doing some testing I noticed a few anomalies with the updated `BufferedLinearInterpolator<T>`. As it turns out, there are more than one approaches a user might need depending upon what they are trying to accomplish and each option really performs best when tweaking some properties within the `BufferedLinearInterpolator<T>` that were not completely exposed. ### Various options: - You might want to enable, disable, or adjust the maximum interpolation time of the last smooth lerp phase for each interpolator type. - You might want to manually adjust the tick latency offset (`NetworkTransform.InterpolationBufferTickOffset`) used depending upon context. - When using a client-server topology, you might want this to be set to something like 0 or 1 (depending upon interpolator). - You might want this value to be higher (like say +2-3 depending on latency and interpolation type) on non-authority instances where the authority is some other client and not the host/server. ### This PR renames `Lerp` to `LegacyLerp` and adds a 3rd new `Lerp` interpolator type: #### Lerp (new) Uses a 1 to 2 phase approach that lerps towards the target, lerps towards the next target (if one exists) ahead by 1 frame delta, blends the two results, and (optionally) smooth the final value. - The first phase lerps towards the current tick state update being processed. - The fourth phase (optional) performs a lerp smoothing where the current respective transform value is lerped towards the result of the first phase at a rate of 1.0f minus the max interpolation time. ## Changelog - Added: `Lerp` interpolation type that still uses a lerp approach but uses the new buffer consumption logic. - Added: Property to enable or disable lerp smoothing for position, rotation, and scale interpolators. - Added: `NetworkTransform.InterpolationBufferTickOffset` static property to provide users with a way to increase or decrease the time marker where interpolators will pull state update from the queue. - Fixed: Issue where the time delta that interpolators used would not be properly updated during multiple fixed update invocations within the same player loop frame. - Changed: The original `Lerp` to be renamed to `LegacyLerp`. ## Testing and Documentation - Includes integration test updates. - Includes documentation for public API entry points. - Includes updates to public documentation for `NetworkTransform`. (Will be adding to [PR-1443](Unity-Technologies/com.unity.multiplayer.docs#1443)) <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> --------- Co-authored-by: Emma <emma.mcmillan@unity3d.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Select the type of change:
Purpose of the Pull Request:
This includes
NetworkTransform
updates based on PR-3337 as well as some updates to the over-allNetworkTransform
documentaiton.This also includes additional updates to NetworkTransform in general.