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

NetworkTransform not synchronizing Y position well on Unity 2022+ versions #2595

Closed
kevincastejon opened this issue Jun 22, 2023 · 9 comments · Fixed by #2624
Closed

NetworkTransform not synchronizing Y position well on Unity 2022+ versions #2595

kevincastejon opened this issue Jun 22, 2023 · 9 comments · Fixed by #2624
Assignees
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report

Comments

@kevincastejon
Copy link

kevincastejon commented Jun 22, 2023

Description

The NetworkTransform transform position synchronization is not working well for the Y axis when used into Unity versions 2022+ (I tested with 2022.3.0 and with 2023.1.0). Prior 2021 versions (tested with 2021.3.23) are working well as intended.
It happens at the end of a jump, the representation of the distant character will remain slightly above the ground.
To ensure that I was not doing things wrong, I tested the bitesize sample (the one which demonstrate client driven movements) on 2021, 2022 and 2023 Unity versions. The issue is happening too with this very sample project, in 2022+.
Even weirder, the issue seems to happen only when there is a movement on one or both of the other axes (X and Z), as an "in-place" jump is synchronized well...

Reproduce Steps

1 - Open the Client Driven bitesize sample on Unity 2022+ (effectively tested on 2022.3.0 and 2023.1.0 with the Host feature)
2 - Jump while moving with one of the character (host or client)
3 - See the desynchronization on the Y axis position on the other end.
4 - Optionally jump "in-place" (aka with no movement on the XZ plane) and the synchronization on the Y axis position on the other end working well as intended.

Actual Outcome

Desynchronization on the Y axis position with the NetworkTransform component while moving on the XZ plane, with Unity version 2022+.

Expected Outcome

No desynchronization, as it is on Unity version 2021.

Screenshots

2021 Unity version - No issue
2021_NO_ISSUE

2022 Unity version - Y position desynchronization Issue when landing while moving on the XZ plane - No issue when jumping 'in-place'
2022_DESYNCH_ON_Y_AXIS_ISSUE

Environment

  • OS: WINDOWS 11
  • Unity Version: 2022.3.0 or 2023.1.0 to reproduce the issue
  • Netcode Version: 1.5.1
  • Netcode Commit: ??? (installed via unity's package manager list)

Additional Context

To clarify once again the context of this desynchronization on the Y axis position issue:

  • Under Unity versions 2022+ (specifically tested with 2022.3.0 and 2023.1.0)
  • At the end of a jump (aka "landing) when simultaneously moving on the XZ plane)
@kevincastejon kevincastejon added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Jun 22, 2023
@kevincastejon kevincastejon changed the title NetworkTransform not synchronizing Y position well on Unity 2022 version (and earlier) NetworkTransform not synchronizing Y position well on Unity 2022 version (and further) Jun 22, 2023
@kevincastejon kevincastejon changed the title NetworkTransform not synchronizing Y position well on Unity 2022 version (and further) NetworkTransform not synchronizing Y position well on Unity 2022+ versions Jun 22, 2023
@NoelStephensUnity
Copy link
Contributor

👀 !!
Wow...I will definitely look into this.
My assumption is you are using a CharacterController?

@NoelStephensUnity
Copy link
Contributor

NoelStephensUnity commented Jun 22, 2023

@kevincastejon
Enable half float precision on the NetworkTransform and see if you still get those visual anomalies...it very well could be a timing related issue with full precision delta detection causing the y axis to get missed towards the end. Half precision uses a delta position algorithm/approach that assures all axis are updated (because the bandwidth cost is reduced).

Let me know if you see the same results on your end?

@kevincastejon
Copy link
Author

👀 !! Wow...I will definitely look into this. My assumption is you are using a CharacterController?

No, the character is Rigidbody+CapsuleCollider+simple controller script. The same issue happen in the Client Driven bitesize sample that is, I believe, using CharacterController.

@kevincastejon Enable half float precision on the NetworkTransform and see if you still get those visual anomalies...it very well could be a timing related issue with full precision delta detection causing the y axis to get missed towards the end. Half precision uses a delta position algorithm/approach that assures all axis are updated (because the bandwidth cost is reduced).

Let me know if you see the same results on your end?

I just tested it and I can confirm the issue is not happening anymore when half float precision is enabled.

@NoelStephensUnity NoelStephensUnity self-assigned this Jun 23, 2023
@NoelStephensUnity NoelStephensUnity removed the stat:awaiting triage Status - Awaiting triage from the Netcode team. label Jun 23, 2023
@NoelStephensUnity
Copy link
Contributor

@kevincastejon
Thank you for confirming that on your end.
I will import this issue and try to get to a fix for that as soon as I get a few more items off my queue.
For now, I would just use half float precision (unless you need the full precision accuracy...most games don't) as it can help reduce your bandwidth consumption by close to 50% (depending upon what all your are synchronizing).
Quaternion Synchronization with Quaternion compression gives you better results if you plan on parenting with varying scale and rotation throughout your hierarchy... and the compressor gets the full quaternion down to 4 bytes per update.

Thank you for your details on reporting this issue. Much appreciated and helpful! 👍

@kevincastejon
Copy link
Author

No problem, I'm glad to help, and thank you for the incoming fix.

@fluong6 fluong6 added stat:imported Issue is tracked internally at Unity and removed stat:import labels Jun 29, 2023
@dawnmichal
Copy link

dawnmichal commented Jul 12, 2023

Looks like I have similar problem. I am using Character controller, but symptoms are same.
I am using ClientNetworkTransform, because I need clients to be able to manage position of their owned characters (don't need full server authoritative solution). Characters are spawned in air and fall to ground. But after landing on ground, characters on not owned clients has different Y axis position (floating above ground) - see screenshots:

  • Client A is owner of black character and see its correct Y position. But other (remote) yelow character floating above ground.
    Client A

  • Client B is owner of yelow character and see opposite.
    Client B

It has something to do with Interpolation. When I turn off Interpolation during Play mode, it will fix character position at all clients. Then I just turn interpolation on again... (I need interpolation for smooth movement). Turning interpolation off and on from time to time work as temporary workaround...

What doesn't work (has no effect):

  • Disabling and enabling ClientNetworkTransform component during Play mode
  • Disabling and enabling position syncing durig Play mode

@NoelStephensUnity
Copy link
Contributor

@dawnmichal
While I do think there could be a synchronization issue, CharacterController can cause issues if it is enabled on non-authoritative instances (in your case non-owners should disable the CharacterController). Just to make sure...are you disabling the CharacterController on the non-owners?

@NoelStephensUnity
Copy link
Contributor

@kevincastejon @dawnmichal
The issue is resolved in #2624 and will be in the next update. Apologies for this regression bug as it was my mistake when adding the half precision and quaternion synchronization/compression capabilities.
The issue was that full precision was not saving the target for transform state updates (i.e. position, rotation, or scale) and was using the current values for each (which changed over time when interpolating). The update will resolve your issues and most likely any other minor quirks you might see when using full precision state updates with interpolation enabled.

@kevincastejon
Copy link
Author

Thank you very much for the work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report
Projects
None yet
4 participants