Errors thrown when using NetworkServer.ReplacePlayerForConnection()

Hi! I’m working on a project right now that gives 2D players the ability to take control of a vehicle. In a related forum post (Question about local authority - Unity Engine - Unity Discussions), I found that NetworkServer.ReplacePlayerForConnection() could be a viable way to give players authority over a vehicle object. I made a hasty implementation of this and soon realized that I needed my original player to retain authority as well - their ability to send commands related to their health would be lost by simply switching the player object for the connection to the vehicle!

Today I’ve taken a second crack at the problem. I made a second “dummy” player (with its own playerControllerId) that exists on each client. This “dummy player” is a prefab carrying a network identity and no render component. I then made it so that NetworkServer.ReplacePlayerForConnection() replaces the authority on the dummy player’s player controller over to the vehicle when the “real” player enters the vehicle, and leaving a vehicle gives authority back to the “dummy player”. I’m getting a strange error thrown with this implementation:

The error above runs as soon as a client player enters a vehicle.
If the player exits the vehicle this next error is thrown:

If a player gets in the vehicle a second time, the error above is thrown every frame. A related RPC (which tells the “real player” object to lock their movement) is running at the same rate, over and over. Any ideas as to what’s going on here?

A little more information: It looks like I have a warning showing up when I spawn the dummy player about a “Duplicate Observer”. This warning comes back up any time I get in or out of the vehicle. Another warning appears just after saying that the “playerControllerId is higher than expected” at a value of 1. I tried changing that to 4, and the error still shows up. I know that the dummy player is spawned through a command on the real player, and I opted not to use ClientScene.AddPlayer() as I wanted a different player object for the dummy. Is that part of my trouble?

yes, you can’t add a player on the server without ClientScene.AddPlayer being called.

FYI 5.2 Networking Stuff (TLDR) - Unity Engine - Unity Discussions

Thanks for the quick reply!

Taking a read through that forum link and through the beta release notes (http://unity3d.com/unity/beta/unity5.2.0b1), I saw part of a bullet point that still left me confused:

Does this mean that whole clients only have authority on one object, or player controllers only have authority on one object? If a whole client only gets authority on one object, isn’t this “dummy fix” still null and void? Do I really have to route the original player’s health and commands through the vehicle?
Edit: Or did that mean that an object can’t have multiple client owners, but clients can own more than one object (so long as it is not already owned by another client)?

right… “an object can’t have multiple client owners, but clients can own more than one object”