Search Unity

How To Set The Network Owner

Discussion in 'Multiplayer' started by ClausKleber, Aug 25, 2015.

  1. ClausKleber

    ClausKleber

    Joined:
    Aug 17, 2015
    Posts:
    6
    Hello,

    I want to change my player character during the game but I cannot figure out how to set the network owner manually.
    I've seen in the manual that they are using the MsgType.Owner for spawning the player objects at the beginning . But I've no idea how to use it.

    I've tried somtihing like this:
    Code (CSharp):
    1. NetworkServer.SendToClient(connectionId, MsgType.Owner, null);
    Does somebody know how to do this in the new unity networking system?

    Thanks a lot!
     
  2. SuperNeon

    SuperNeon

    Joined:
    Mar 16, 2014
    Posts:
    85
  3. ClausKleber

    ClausKleber

    Joined:
    Aug 17, 2015
    Posts:
    6
    Thank you for your answer.

    I've tried it but it seems that ReplacePlayerForConnection() doesn't inform the client which gets the new object. On server the authority flag is set correctly but not on client.
    Do I have to call ReplacePlayerForConnection() on client too? But in this case which NetworkConnection should I take? connectionToServer?

    Thanks for the help!