Search Unity

Switch between GameObject control through authority ?

Discussion in 'Multiplayer' started by Spiksou, Feb 13, 2018.

  1. Spiksou

    Spiksou

    Joined:
    Mar 25, 2014
    Posts:
    1
    Hello all,

    I'm working on a my first multiplayer project. Here is the idea : there is many spawned Game Object. Each player on client can select a Game Object that is "available" and move it through keyboard. By clicking "Esc", the Game Object is "available" again.

    By "available", I've understand I've to use authority. Is it ?

    Whats is the best way to manage this : AssignClientAuthority (need to be local player auth) or ReplacePlayerForConnection (don't understand clearly how to use it)?

    Thank you !
    Alexis
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    ReplacePlayerForConnection is when you want to change the client's Player GameObject. You'd normally only do that for something like an RPG game where the player switches classes from warrior to wizard, etc. Just moving objects around you wouldn't need to do that.

    So to move objects around, you can choose to assign client authority and then you can have that client move the object around. You could also send a Command on that client's player gameobject to the server to tell the server to move the object around, without needing to assign authority of the object to the client. There's more ways too, such as doing it all with Messages.