Search Unity

NetworkTransform not working on client

Discussion in 'Multiplayer' started by TerabyteTim, Jun 20, 2015.

  1. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    115
    So I'm trying to sync movement between two programs using UNET. I have them connecting fine, and seeing eachother/registering the player controllers. When I move the network player on the host that has "Local Player Authority" checked and a NetworkTransform component, I see it move on both the host and the client. However when I move the second object on the client, which has "Local Player Authority" checked on the client but not the server, I don't see it move on the server. Is there something special I need to set up in order for NetworkTransform to broadcast data from the client to the server?
     
    ahungrybear likes this.
  2. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    If you want to send data from client to server, the object must be a player object.
    Prefabs in the NetworkManager will be player object automatically, other objects have to be added (on the server, not on the client) with NetworkManager.AddPlayerForConnection(playerConnection, yourGameObject, aNewControllerID);
     
  3. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    115
    Yeah, I have my network player in the NetworkManager's "Player Prefab" field
     
  4. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    115
    My NetworkPlayer prefab has a NetworkIdentity script, a NetworkTransform script, and a NetworkBehaviour script.
     
  5. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    That should be right. But LocalPlayerAuthority should be the same on server and client, not just client alone.
    If you deactivate it on the server, I think the server ignores incoming messages (since you declared that it shouldn't get LocalPlayerAuthority)
    The checkbox just says "this object can be controlled by the owner".
     
  6. TerabyteTim

    TerabyteTim

    Joined:
    Oct 20, 2011
    Posts:
    115
    Weird, if you only set some of them to "Local Player Authority" it doesn't work, but if you set every instance of a player object in the scene to that it works. It's functioning now, thanks a ton!
     
  7. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    I'm having this same issue. Client transform is being synchronized on the Server/Host, but Server/Host transform isn't being updated on the Client. I have "Local Player Authority" checked and the objects have a NetworkIdentity and a NetworkTransform. They have a script for input/movement using velocity (the objects have rigidbodies), and the NetworkTransform component has "Sync Rigidbody 3D" selected.

    EDIT - I also tried enabling "Multiple Client Mode", but it disables itself when entering play mode.
     
    Last edited: Jun 30, 2015
    rajiv-c and christophermrau like this.
  8. brickbrick

    brickbrick

    Joined:
    Aug 31, 2015
    Posts:
    1
    I'm having the same problem re. "Multiple Client Mode" disabling itself whenever I enter play mode or build my project. If I build my project and then run it simultaneously in Unity, I am unable to connect as a client in one game player while the other is hosting, unless I type in an address besides localhost (which is the hosting address) i.e. it seems like it won't let me have more than one client (the only client it is allowing is the host). I feel as though enabling Multiple Client Mode should fix this, but I can't enable it!!
     
  9. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    683
    I ended up solving (I guess you could call it that) the issue by rebuilding the player prefab from scratch. I made sure to attach the NetworkTransform component last, and it's working fine now.
     
    StarShade88 likes this.
  10. desertkun

    desertkun

    Joined:
    Jan 13, 2016
    Posts:
    8
    Sorry for old thread, but in case anyone still wonders how to enable checkbox "Multiple Client Mode":

    Code (CSharp):
    1. Utility.useRandomSourceID = true;
    Yep, GUI lies, I've searched thought sources and found this:
    Code (CSharp):
    1. Utility.useRandomSourceID = EditorGUILayout.Toggle("Multiple Client Mode:", Utility.useRandomSourceID);
     
  11. rajiv-c

    rajiv-c

    Joined:
    Aug 4, 2015
    Posts:
    2
    I was getting same issue and it got solved when I have attached the NetworkTransform component last.
     
  12. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    That sounds like the problem is due to Order of execution. You are probably executing movement code on remote objects and when you added it last it just so happend to have a different order. Just my speculation.
     
    rajiv-c likes this.
  13. jfa257

    jfa257

    Joined:
    Jul 17, 2013
    Posts:
    9
    wlwl2 and sun_stealer like this.
  14. sun_stealer

    sun_stealer

    Joined:
    Oct 4, 2016
    Posts:
    24
    @jfa257 I also read this in the documentation, and it's extremely confusing. What's the difference between a NetworkTransform object that exists in the scene from the beginning, and the spawned one? Why the former won't synchronize?
     
  15. jfa257

    jfa257

    Joined:
    Jul 17, 2013
    Posts:
    9
    well, basically I presume the spawned one has a reference both ways, server/client and client/server. I tested it and the server can send network updates to the client (tested with a network transform prefab that was not spawned), but since the object its not in the list of spawned objects, when the client tries to send an update, its not possible, to the point of classes not running methods because the transform parameters are not allowed to be updated.
     
  16. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    Important, for 2018 we determined that

    There is some flakiness with NetworkTransform if you are using localhost during development, perhaps particularly on Mac.

    if you have a NetworkTransform with local authority system, it often erratically WILL NOT WORK when you are testing it in a localhost setting.

    (Further, this might sound bizarre but I found that - say you have a few PCs/Macs on your desktop, once you "do" do it over a LAN, the project will in fact then work (sometimes?) via localhost, which seems unbelievable but seemed to happen!)

    In short, if you are experiencing this incredibly annoying problem, it's really worth getting the project on a few actual machines on LAN, get away from localhost testing. S***ty issue.
     
  17. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
  18. RiverCanvas

    RiverCanvas

    Joined:
    Jun 5, 2017
    Posts:
    2
    Same issue Here. But I already had NetworkTransform component last. Solved it by placing it on top.
     
    Vonzie likes this.
  19. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    that's interesting, @RiverCanvas , maybe that explains the "erratic behavior when testing with localhost", happy new year
     
  20. unity_7EOgRZp31vlLtA

    unity_7EOgRZp31vlLtA

    Joined:
    May 4, 2019
    Posts:
    1
    I have the same bug. I placed the Network Transform on top and nothing worked, if i place it in the bottom it isnt working.
    I dont get it what is causing the bug.
    Pls let me know if someone finds a solution.
     
  21. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    sucks doesn't it ? @unity_7EOgRZp31vlLtA the only thing we have found is that "it is flakey" and that's that, it seems.

    I guess Unity are (again) totally changing the networking soon, so .. who knows.
     
  22. Khudere

    Khudere

    Joined:
    Jun 7, 2014
    Posts:
    9
    Was having issues and moving it last fixed the problem. Thanks for this thread
     
  23. diemekalombo9

    diemekalombo9

    Joined:
    Feb 16, 2023
    Posts:
    1
    I looked in the comments section of a video and this is something I found. Hopefully it helps!

    Screenshot (21).png