Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved Owner authoritative network transform interpolates fine on client side but does not on server?

Discussion in 'Netcode for GameObjects' started by Bruugle, Sep 13, 2023.

  1. Bruugle

    Bruugle

    Joined:
    Oct 12, 2020
    Posts:
    17
    I have a project I am making that used Owner authoritative physics movement and I am getting some strange behavior.

    My solution for owner authoritative transforms was the one provided here in the user manual.


    Code (CSharp):
    1. using Unity.Netcode.Components;
    2. using UnityEngine;
    3.  
    4. namespace Unity.Multiplayer.Samples.Utilities.ClientAuthority
    5. {
    6.     /// <summary>
    7.     /// Used for syncing a transform with client side changes. This includes host. Pure server as owner isn't supported by this. Please use NetworkTransform
    8.     /// for transforms that'll always be owned by the server.
    9.     /// </summary>
    10.     [DisallowMultipleComponent]
    11.     public class ClientNetworkTransform : NetworkTransform
    12.     {
    13.         /// <summary>
    14.         /// Used to determine who can write to this transform. Owner client only.
    15.         /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform.
    16.         /// </summary>
    17.         protected override bool OnIsServerAuthoritative()
    18.         {
    19.             return false;
    20.         }
    21.     }
    22. }
    In my project there is the ability to switch ownership of the plane object from player to player. In the video below I start by having the server (host is the editor copy) have ownership of the plane. As you can see the client side interpolation is working smoothly and great. But, at exactly half way through, I change ownership and hand it over to the client and you can see the interpolation on the host end becomes terrible. I am struggling to find out why this would be so. I also tested a scenario with one host and two connected clients and tried the same test. When i handed ownership over to one of the clients, the other client (non-host) interpolated just fine. It seems to only be the host that cannot interpolate client authoritative network transforms. maybe someone could help me out and look into this?
     
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @Bruugle , thanks for highlighting the issue and sharing the video. Would it be possible for you to open a bug report here? In this way, the team behind Netcode For GameObject will be able to prioritize your fix, and you'll be automatically updated about its status.
     
  3. Bruugle

    Bruugle

    Joined:
    Oct 12, 2020
    Posts:
    17
    Turns out the jitter was from something i overlooked in my camera code! interpolation is now working as expected.
     
    RikuTheFuffs-U likes this.