Skip to content

Commit 20ad052

Browse files
fix: NetworkTransform was not ending extrapolation for some states. [MTT-4521] (#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 <[email protected]>
1 parent b6a68e7 commit 20ad052

File tree

5 files changed

+571
-141
lines changed

5 files changed

+571
-141
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ Additional documentation and release notes are available at [Multiplayer Documen
1111

1212
### Fixed
1313

14-
- Fixed ClientRpcs always reporting in the profiler view as going to all clients, even when limited to a subset of clients by ClientRpcParams. (#2144)
15-
- Fixed RPC codegen failing to choose the correct extension methods for FastBufferReader and FastBufferWriter when the parameters were a generic type (i.e., List<int>) and extensions for multiple instantiations of that type have been defined (i.e., List<int> and List<string>) (#2142)
14+
- Fixed issue where `NetworkTransform` was not ending extrapolation for the previous state causing non-authoritative instances to become out of synch. (#2170)
15+
- Fixed issue where `NetworkTransform` was not continuing to interpolate for the remainder of the associated tick period. (#2170)
16+
- 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. (#2170)
17+
- Fixed issue where `NetworkTransform` was not honoring the InLocalSpace property on the authority side during OnNetworkSpawn. (#2170)
1618
- Implicit conversion of NetworkObjectReference to GameObject will now return null instead of throwing an exception if the referenced object could not be found (i.e., was already despawned) (#2158)
17-
- Fixed throwing an exception in OnNetworkUpdate causing other OnNetworkUpdate calls to not be executed. (#1739)
1819
- Fixed warning resulting from a stray NetworkAnimator.meta file (#2153)
20+
- Fixed ClientRpcs always reporting in the profiler view as going to all clients, even when limited to a subset of clients by `ClientRpcParams`. (#2144)
21+
- Fixed RPC codegen failing to choose the correct extension methods for `FastBufferReader` and `FastBufferWriter` when the parameters were a generic type (i.e., List<int>) and extensions for multiple instantiations of that type have been defined (i.e., List<int> and List<string>) (#2142)
22+
- Fixed throwing an exception in `OnNetworkUpdate` causing other `OnNetworkUpdate` calls to not be executed. (#1739)
1923

2024
## [1.0.1] - 2022-08-23
2125

com.unity.netcode.gameobjects/Components/Interpolator/BufferedLinearInterpolator.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ public void AddMeasurement(T newMeasurement, double sentTime)
248248
return;
249249
}
250250

251+
// Part the of reason for disabling extrapolation is how we add and use measurements over time.
252+
// TODO: Add detailed description of this area in Jira ticket
251253
if (sentTime > m_EndTimeConsumed || m_LifetimeConsumedCount == 0) // treat only if value is newer than the one being interpolated to right now
252254
{
253255
m_LastBufferedItemReceived = new BufferedItem(newMeasurement, sentTime);
@@ -292,7 +294,9 @@ public class BufferedLinearInterpolatorFloat : BufferedLinearInterpolator<float>
292294
/// <inheritdoc />
293295
protected override float InterpolateUnclamped(float start, float end, float time)
294296
{
295-
return Mathf.LerpUnclamped(start, end, time);
297+
// Disabling Extrapolation:
298+
// TODO: Add Jira Ticket
299+
return Mathf.Lerp(start, end, time);
296300
}
297301

298302
/// <inheritdoc />
@@ -311,13 +315,17 @@ public class BufferedLinearInterpolatorQuaternion : BufferedLinearInterpolator<Q
311315
/// <inheritdoc />
312316
protected override Quaternion InterpolateUnclamped(Quaternion start, Quaternion end, float time)
313317
{
314-
return Quaternion.SlerpUnclamped(start, end, time);
318+
// Disabling Extrapolation:
319+
// TODO: Add Jira Ticket
320+
return Quaternion.Slerp(start, end, time);
315321
}
316322

317323
/// <inheritdoc />
318324
protected override Quaternion Interpolate(Quaternion start, Quaternion end, float time)
319325
{
320-
return Quaternion.SlerpUnclamped(start, end, time);
326+
// Disabling Extrapolation:
327+
// TODO: Add Jira Ticket
328+
return Quaternion.Slerp(start, end, time);
321329
}
322330
}
323331
}

0 commit comments

Comments
 (0)