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 23 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
238 changes: 160 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 @@ -313,6 +313,8 @@ public IEnumerator SetUp()
}
else
{
// Setup the frames per tick for time travel to next tick
ConfigureFramesPerTick();
OnInlineSetup();
}

Expand Down Expand Up @@ -1544,8 +1546,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 +1591,6 @@ public static void TimeTravelToNextTick()
{
frameRate = 60;
}

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