Skip to content
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

fix: NetworkTransform Mixed Unreliable & Reliable Order of Operations #2777

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
500f2be
fix
NoelStephensUnity Nov 24, 2023
f33a749
style
NoelStephensUnity Nov 25, 2023
7f900f4
update
NoelStephensUnity Nov 25, 2023
ea68a6c
update
NoelStephensUnity Nov 25, 2023
6766554
test
NoelStephensUnity Nov 25, 2023
2b86619
update and test
NoelStephensUnity Nov 25, 2023
f0ec204
update and style
NoelStephensUnity Nov 26, 2023
6c5cbb0
fix
NoelStephensUnity Nov 26, 2023
5066a50
update
NoelStephensUnity Nov 27, 2023
cfaf940
update
NoelStephensUnity Nov 27, 2023
2aad303
style
NoelStephensUnity Nov 27, 2023
741e3be
Merge branch 'develop' into fix/networktransform-unreliable-reliable-…
NoelStephensUnity Nov 27, 2023
3fee9ba
style
NoelStephensUnity Nov 27, 2023
919ff84
Merge branch 'develop' into fix/networktransform-unreliable-reliable-…
NoelStephensUnity Nov 28, 2023
078bd9d
fix & update
NoelStephensUnity Dec 1, 2023
7dfb093
update
NoelStephensUnity Dec 1, 2023
2880118
style
NoelStephensUnity Dec 1, 2023
cbc7632
test fix
NoelStephensUnity Dec 2, 2023
9919413
Merge branch 'develop' into fix/networktransform-unreliable-reliable-…
NoelStephensUnity Dec 2, 2023
666b7bc
test fix and update
NoelStephensUnity Dec 2, 2023
2980308
style
NoelStephensUnity Dec 2, 2023
3778b84
update
NoelStephensUnity Dec 2, 2023
0709cd3
style
NoelStephensUnity Dec 3, 2023
234f652
update
NoelStephensUnity Dec 4, 2023
48b93c0
Merge branch 'develop' into fix/networktransform-unreliable-reliable-…
NoelStephensUnity Dec 4, 2023
48978cb
style
NoelStephensUnity Dec 4, 2023
621228d
update
NoelStephensUnity Dec 4, 2023
1e67b34
style
NoelStephensUnity Dec 4, 2023
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
3 changes: 3 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

- Fixed issue where a teleport state could potentially be overridden by a previous unreliable delta state. (#2777)
- Fixed issue where `NetworkTransform` was using the `NetworkManager.ServerTime.Tick` as opposed to `NetworkManager.NetworkTickSystem.ServerTime.Tick` during the authoritative side's tick update where it performed a delta state check. (#2777)
- Fixed issue where a parented in-scene placed NetworkObject would be destroyed upon a client or server exiting a network session but not unloading the original scene in which the NetworkObject was placed. (#2737)
- Fixed issue where during client synchronization and scene loading, when client synchronization or the scene loading mode are set to `LoadSceneMode.Single`, a `CreateObjectMessage` could be received, processed, and the resultant spawned `NetworkObject` could be instantiated in the client's currently active scene that could, towards the end of the client synchronization or loading process, be unloaded and cause the newly created `NetworkObject` to be destroyed (and throw and exception). (#2735)
- Fixed issue where a `NetworkTransform` instance with interpolation enabled would result in wide visual motion gaps (stuttering) under above normal latency conditions and a 1-5% or higher packet are drop rate. (#2713)

### Changed

- Changed `NetworkTransform.SetState` (and related methods) now are cumulative during a fractional tick period and sent on the next pending tick. (#2777)
- `NetworkManager.ConnectedClientsIds` is now accessible on the client side and will contain the list of all clients in the session, including the host client if the server is operating in host mode (#2762)
- Changed `NetworkSceneManager` to return a `SceneEventProgress` status and not throw exceptions for methods invoked when scene management is disabled and when a client attempts to access a `NetworkSceneManager` method by a client. (#2735)
- Changed `NetworkTransform` authoritative instance tick registration so a single `NetworkTransform` specific tick event update will update all authoritative instances to improve perofmance. (#2713)
Expand Down
245 changes: 167 additions & 78 deletions com.unity.netcode.gameobjects/Components/NetworkTransform.cs

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,12 @@ protected virtual void OnInlineSetup()
public IEnumerator SetUp()
{
VerboseDebug($"Entering {nameof(SetUp)}");

NetcodeLogAssert = new NetcodeLogAssert();
if (m_EnableTimeTravel)
{
// Setup the frames per tick for time travel advance to next tick
ConfigureFramesPerTick();
}
if (m_SetupIsACoroutine)
{
yield return OnSetup();
Expand Down Expand Up @@ -1544,8 +1548,42 @@ protected static void TimeTravel(double amountOfTimeInSeconds, int numFramesToSi
}
}

protected virtual uint GetTickRate()
{
return k_DefaultTickRate;
}

protected virtual int GetFrameRate()
{
return Application.targetFrameRate == 0 ? 60 : Application.targetFrameRate;
}

private int m_FramesPerTick = 0;
private float m_TickFrequency = 0;

/// <summary>
/// Recalculates the <see cref="m_TickFrequency"/> and <see cref="m_FramesPerTick"/> that is
/// used in <see cref="TimeTravelAdvanceTick"/>.
/// </summary>
protected void ConfigureFramesPerTick()
{
m_TickFrequency = 1.0f / GetTickRate();
m_FramesPerTick = Math.Max((int)(m_TickFrequency / GetFrameRate()), 1);
}

/// <summary>
/// Helper function to time travel exactly one tick's worth of time at the current frame and tick rates.
/// This is NetcodeIntegrationTest instance relative and will automatically adjust based on <see cref="GetFrameRate"/>
/// and <see cref="GetTickRate"/>.
/// </summary>
protected void TimeTravelAdvanceTick()
{
TimeTravel(m_TickFrequency, m_FramesPerTick);
}

/// <summary>
/// Helper function to time travel exactly one tick's worth of time at the current frame and tick rates.
/// ** Is based on the global k_DefaultTickRate and is not local to each NetcodeIntegrationTest instance **
/// </summary>
public static void TimeTravelToNextTick()
{
Expand All @@ -1555,7 +1593,6 @@ public static void TimeTravelToNextTick()
{
frameRate = 60;
}

var frames = Math.Max((int)(timePassed / frameRate), 1);
TimeTravel(timePassed, frames);
}
Expand Down
Loading
Loading