1

I have a question regarding the UNET system.

There are some objects in the scene that can be picked. I want to synchronize transform that object when a player picks it up.

The object has a NetworkIdentity component with LocalPlayerAuthority checked. It also has a NetworkTransform script, but the transform synchronizes only from host to clients, not the other way around. So if I move the object on the host side all clients see the change, but if the client moves it only that particular client sees the change. What do I need to do in order to make it synchronized on both sides?

Bono
  • 4,757
  • 6
  • 48
  • 77

1 Answers1

0

Never mind, I already solved this problem.

What I had to do is to AssignLocalAuthority of the non-player object by using player object.

  • will you like to share the code snippet in the answer too? i am encouting the same problem but don't how to set it.Thanks – Muhammad Faizan Khan Feb 07 '17 at 11:14
  • 1
    On the player object, call `AssignLocalAuthority` in a command function (to invoke it on the host side) with the parameter of the netId of the non-player object. You can get netId from the NetworkIdentity component. I assign authority on a non-player object like this. Hope it helps: `NetworkManagerVR.Instance.localNetworkPlayer.CmdAssignObjectAuthority(GetComponent().netId);` – Milan Doležal Feb 08 '17 at 12:30
  • Thanks, but you should add it in the answer, for future user also. – Muhammad Faizan Khan Feb 09 '17 at 04:26
  • I check that non-player object authority automatically assign to host. Is this correct? because if i made host then i can interact with non-player object directly and their position/rot sync across network smoothly. while same is not true for the client – Muhammad Faizan Khan Feb 09 '17 at 04:29