How To Set The Network Owner

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:

NetworkServer.SendToClient(connectionId, MsgType.Owner, null);

Does somebody know how to do this in the new unity networking system?

Thanks a lot!

You can use this function to change the player character:
http://docs.unity3d.com/ScriptReference/Networking.NetworkServer.ReplacePlayerForConnection.html

You can send your own network message to specify which prefab to use.
MsgType.Owner is used internally by unity in NetworkManager.

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!