Search Unity

Question NetworkTransform scene placed objects do not sync when moved before client joins.

Discussion in 'Netcode for GameObjects' started by TestifyNow, Sep 30, 2022.

  1. TestifyNow

    TestifyNow

    Joined:
    Feb 9, 2016
    Posts:
    24
    The only fix I've found so far is changing the position amount to 0, which essentially renders it always dirty.
    Probably the best solution is to add OnClientConnected SetDirty, but I'm going to sleep so haven't had time to test this, besides, I'm sure there's a way to do this properly that I'm just not aware of.
     
    PierreNS likes this.
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    I don't think that ever happened in my tests. Ie when I'm the host and move around, then join with another client, I can see the host at its current position right away.

    I did notice this once with a NetworkVariable (player name) that each player owns, where the new client would not see the current state of the variable of the host. Haven't debugged the issue though, I did the same as you: set the variable to an empty string and back to its actual name for now.
     
  3. TestifyNow

    TestifyNow

    Joined:
    Feb 9, 2016
    Posts:
    24
    Oh yeah, I forgot to mention. Players seem to sync fine.
    It's just all the different objects (prefabs) that are placed in scene that seem not to :D
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    In-scene placed vs spawned at runtime, right?

    I'm currently struggling (though I'm in the 2022.2 beta) with a prefab in the scene which simply won't execute / participate in networking in the first run of playmode after a recompile. Could be related. Maybe I can isolate the issue over the weekend, it's getting annoying.
     
    PierreNS likes this.
  5. TestifyNow

    TestifyNow

    Joined:
    Feb 9, 2016
    Posts:
    24
    This sounds weird, but yeah, I think they should really sit and fix all those little annoyances, I was lead to believe this was in development for years, so I expected something a little more stable to be honest... Especially when 1.0 went out of preview.

    Unity never fails to suprise me.
     
  6. TestifyNow

    TestifyNow

    Joined:
    Feb 9, 2016
    Posts:
    24
    Anyone has good idea on how to set networktransform to dirty? because IsDirty cannot be changed called as it's internal... Also, is this gonna get fixed in netcode itself or are we supposed to handle this ourselves?? It seems very basic to me
     
  7. PierreNS

    PierreNS

    Joined:
    Jan 5, 2021
    Posts:
    2
    Anybody that have a solution for this ?
    If i host a game and move my character then join the game the hosts character is still at the spawn point on the client that just joined, its not until the host moves that the character gets synced to the real position on the client.
     
  8. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi, have you tried calling NetworkObject.Spawn() on these instances? (doc here)
     
  9. bluepilkintonching

    bluepilkintonching

    Joined:
    Nov 29, 2019
    Posts:
    30
    I have this exact issue. The characters are being spawned with NetworkObject.SpawnWithOwnership(). When the connected client spawns in, the host's character appears at the spawn point. (The host is using a simple ClientNetworkTransform). When the host then moves the character, its position on the connected client does a weird teleport, and finally begins syncing its position on the client properly.

    Any idea on how to fix?

    EDIT: A workaround I've found, is to set the position threshold on the ClientNetworkTransform to 0. This is kind of a stink fix, it uses up lots of bandwidth. And it still has a teleport issue where when once the scene becomes loaded on the client, the host's character will teleport from the spawn point to its position on the server. At least it means the position syncs properly though from the get-go.

    This also appears to be an issue with the regular NetworkTransform component as well.

    Any better solutions to this? Or should I submit it as a bug?
     
    Last edited: Jan 18, 2023
  10. bluepilkintonching

    bluepilkintonching

    Joined:
    Nov 29, 2019
    Posts:
    30
  11. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hey @bluepilkintonching , If this is not working as expected, I'd recommend to submit a bug. Bumping threads on the forum does not have the same visibility of a submitted bug.

    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.
     
    bluepilkintonching likes this.