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

feat: NetworkTransformHybrid - Hybrid Sync Part 1 #3937

Merged
merged 26 commits into from
Nov 7, 2024
Merged

Conversation

miwarnec
Copy link
Collaborator

@miwarnec miwarnec commented Oct 29, 2024

TODO DONT MERGE YET:

  • interp in lateupdate

Changing Mirror from Reliable to (optional) Unreliable takes significant effort.
Let's do this with incremental PRs, each of them tested in a production game.

  1. NetworkTransform Hybrid baseline+deltas
  2. Delta Compression via Half Floats
  3. Abstract NetworkTransform Hybrid sync into NetworkBehaviourHybrid
  4. Use NetworkBehaviourHybrid for more components
  5. Implement OnSerializeUnreliable to remove Rpc overhead
  6. Move NetworkBehaviourHybrid into NetworkBehaviour core
  7. IL Weaving for Unreliable [SyncVar] support etc.

This PR is step 1: NetworkTransform with Reliable baseline + Unreliable deltas for proper change detection!

Old NetworkTransform

The previous NetworkTransform implements a hacky, 95% correct change detection for Unreliable since bandwidth would be too high otherwise. This PR changes this to a 100% correct change detection - so we'll want this even if we don't go any further!

Benchmarks

Mirror Benchmark:
Same bandwidth, faster server + client perf.
image

@MrGadget1024 MrGadget1024 added work in progress Need more time to decide. Nothing to do here for now. enhancement New feature or request labels Oct 29, 2024
Comment on lines +97 to +98
public bool showGizmos;
public bool showOverlay;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flags enum

Comment on lines 79 to 92
public bool unreliableRedundancy = false;

[Tooltip("When sending a reliable baseline, should we also send an unreliable delta or rely on the reliable baseline to arrive in a similar time?")]
public bool baselineIsDelta = true;

// selective sync //////////////////////////////////////////////////////
[Header("Selective Sync & interpolation")]
public bool syncPosition = true;
public bool syncRotation = true;
// public bool syncScale = false; // rarely used. disabled for perf so we can rely on transform.GetPositionAndRotation.

// BEGIN CUSTOM CHANGE /////////////////////////////////////////////////
// TODO rename to avoid double negative
public bool disableSendingThisToClients = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flags enum

// only sync when changed hack /////////////////////////////////////////
[Header("Sync Only If Changed")]
[Tooltip("When true, changes are not sent unless greater than sensitivity values below.")]
public bool onlySyncOnChange = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flags enum

Copy link
Collaborator

@MrGadget1024 MrGadget1024 left a comment

Choose a reason for hiding this comment

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

Fix typos

Copy link
Collaborator

@MrGadget1024 MrGadget1024 left a comment

Choose a reason for hiding this comment

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

fix typos

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing mirror icon ;)

Comment on lines 57 to 58
Vector3 lastDeserializedBaselinePosition = Vector3.zero;
Quaternion lastDeserializedBaselineRotation = Quaternion.identity;
Copy link
Contributor

Choose a reason for hiding this comment

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

"assigned, but never used"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep, needed for delta compression. gonna put comments on there

@miwarnec miwarnec changed the title Hybrid Sync Part 1: NetworkTransform Hybrid feat: NetworkTransformHybrid - Hybrid Sync Part 1 Nov 7, 2024
@miwarnec miwarnec merged commit 499e4da into master Nov 7, 2024
8 checks passed
@miwarnec miwarnec deleted the quake_nt2022_fast branch November 7, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work in progress Need more time to decide. Nothing to do here for now.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants