Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Multiplayer NetworkTransform on Scene Object not working

Discussion in 'Connected Games' started by BoraxKid, Apr 27, 2017.

  1. BoraxKid

    BoraxKid

    Joined:
    Dec 1, 2016
    Posts:
    3
    Hi,

    First of all, I'm using Unity 5.6.0f1 (with a Unity Plus license).

    I'm trying to sync the transform of a scene object between every clients, but it only works from the local client/host to the clients.
    The game object has a NetworkIdentity and a NetworkTransform.

    When the host moves the game object, the transform is synced on all clients.
    But when a client (not the host) moves the game object, the transform is not synced on any clients.

    Can you help me out?

    Thanks a lot.
     
  2. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    535
    Generally speaking almost everything is synced from Server --> Client. In your case the client is able to change the transform's position, but no data is sent from Client --> Server.

    The only cases where NetworkIdentity data is sent from Client --> Server is if the client has authority of the networkedObject. Because those scene objects are controlled by the server the client has no authority of them. NetworkTransform will never send data from Client --> Server even if the client changes it's position.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,593
    Does the client moving the object have authority over the object?
     
  4. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    535
    He said they are scene objects, so no I don't believe the client will have authority.

    I only think things like SpawnWithClientAuthority, AssignClientAuthority, or AddPlayerForConnection give authority.
     
  5. BoraxKid

    BoraxKid

    Joined:
    Dec 1, 2016
    Posts:
    3
    In that case, is it possible to give authority of the networked object to multiple clients ?
     
  6. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    535
    No, I believe only 1 client can have authority. If you want multiple clients to be able to act on 1 object I suggest using MessageBase to send data to the server. Then you will have to code on the server how to handle the fighting between clients that are all trying to control the same object.
     
  7. BoraxKid

    BoraxKid

    Joined:
    Dec 1, 2016
    Posts:
    3
    Thanks,
    I solved it by assigning local authority when the object is picked up by a player, and removing the authority when the player releases the object.
     
  8. Staggan

    Staggan

    Joined:
    Jul 9, 2015
    Posts:
    10
    Hello BoraxKid

    I know this is an older thread but can you share your code for doing this? I am having a similar issue..

    Thanks
     
  9. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    352
    Important .. for 2018 ..

    we determined

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

    it's a real PITA. Be sure to test on normal LAN with a few machines.