Search Unity

Best practice for Network Objects controlled by all players

Discussion in 'Multiplayer' started by pojoih, Jun 14, 2016.

  1. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    What's the best practice for networked objects, which should be controllable by all players?
    I have a VideoPlayer in my unity app, which is synced for all clients via UNET. All clients should have control over play/pause/seek/loadvideo etc.

    It's currently a host object, so clients don't have authority. Is it a good idea to implement a command call on player objects to request authority with "NetworkIdentity.AssignClientAuthority()" or is there an easier way?
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I would have every client spawn a player object that is nothing but a NetworkIdentity and a script with some [Commands] in it. When the player script on the server receives a command from one of the clients it can then call a method on your server owned VideoPlayer that sends a [ClientRPC] back out to all the clients to play/pause/etc

    I don't think you should ever need to AssignClientAuthority
     
    Last edited: Jun 14, 2016
    Chom1czek likes this.