Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NetworkTransform on Scene Object not working

Discussion in 'Multiplayer' started by BoraxKid, Apr 27, 2017.

  1. BoraxKid

    BoraxKid

    Joined:
    Dec 1, 2016
    Posts:
    6
    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:
    651
    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:
    11,847
    Does the client moving the object have authority over the object?
     
  4. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    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:
    6
    In that case, is it possible to give authority of the networked object to multiple clients ?
     
  6. Zullar

    Zullar

    Joined:
    May 21, 2013
    Posts:
    651
    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:
    6
    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:
    476
    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.