Search Unity

Player object to server object

Discussion in 'Multiplayer' started by Royall, Oct 22, 2016.

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    121
    Hi guys,

    Getting very confused about ReplacePlayerForConnection to turn a player into a server object.
    I want my player object to remain in the scene when it is replaced (Acts as a player corpse) with a new player object.

    The weird thing is that when I look at the network information about the corpse object it still says it has a playercontrollerid of 0 while nonplayer objects have a playercontrollerid of -1.

    Code (CSharp):
    1. NetworkServer.ReplacePlayerForConnection(replacePlayer.GetComponent<NetworkIdentity>().connectionToClient, o, 0);
    I have a feeling the old object still has some kind of relation to the client connection which is not what I want.

    Anyone has an idea?

    Cheers