- Home /
Network view , ownership
hi, after creating a server and joining with a client , it is supposed that the client can control the object , but it is only able to view it and make Local changes to it, while the server is able to change it globally , how can i reverse that ? i am not using RPCs i am using Network View Reliable Delta Compression
Answer by Bunny83 · Sep 10, 2012 at 01:43 AM
The owner of a NetworkView is defined by the owner of the NetworkViewID. The owner of a NetworkViewID can't be changed. The owner is set to the peer that creates the ViewID.
Whenever someone calls Network.Instantiate and the instantiated object contains a NetworkView, Unity will automatically create / allocate a ViewID for each NetworkView. Those get send to the other users via RPC. The person that calls Network.Instantiate is automatically the owner of the object.
To create / allocate a ViewID manually you can use Network.AllocateViewID, but you have to take care of distributing it across the Network, usually with RPCs. This would be the only way to "change" the owner after an object has been instantiated.
So in your case just make sure the objects get instantiated by the desired owner.
If you want to change the owner of a NetworkView, you have to use an RPC and send a new NetworkViewID (allocated by the new owner) to everyone and replace the old one. Keep in mind when your prefab contains multiple NetworkViews, you need a new ViewID for each of them.
Your answer
Follow this Question
Related Questions
Network Instantiate with wrong owner. 2 Answers
Assigning the owner of networkviews manually 1 Answer
Server 24/7 and NetworkID owner 1 Answer
network.RPC behavior 1 Answer
Network View mess up colliders? 0 Answers