- Home /
UNET - Players Spawn With Misplaced Authority
Background
I'm new to UNET, but not to multiplayer in general. I'm having some trouble with UNET's basics due to very incomplete documentation. The tutorials/manual pages are more complete, but are not relevant to what I'm trying to do, as far as I can tell (and I've read them through), since they only detail use of drag-and-drop with regard to players, and not any do-it-yourself methods. I'm combining split-screen multiplayer and networked multiplayer.
What's working:
When I spawn players from the host, players spawn fine, have authority, etc. Split screen works beautifully (locally.) And for that matter, all the clients can see the actions undertaken on the host.
My problem:
When I spawn players from any other client, they spawn, I can set their viewports, etc., but they are not given local authority by the server. They only have authority on the server/host (and they shouldn't.) They're only partially controllable on the client that requested them (rotation is deliberately undone by their NetworkTransform since they don't have authority), and the movement isn't transmitted to other clients or the host.
What I'm doing:
I'm using a class that inherits from NetworkManager (CustomNetworkManager) on both the client and the server to coordinate and execute spawning. It is identical for clients and hosts, but I assume that the obvious, premade, server-only functions still only execute on the server. The client (wherever it may be) calls AddPlayer(ClientScene.readyConnection) with a player controller specified. I think that triggers OnServerAddPlayer() on the server, which then instantiates the player on the server and spawns the player for everybody else. And it should give the player local authority on the client that requested it, right?
Where have I gotten it wrong?
(Extra info)
Latest Unity release, 5.3.0f4.
Everything has NetworkIdentities, and the players have NetworkTransforms. I'm using various premade materials right now, such as the first person controller and mouselook.cs.
On the server, the inspector's "Network Information" for each host-spawned player says yes on all counts.
On the clients, the "Network Information" for the client-spawned players say yes for isClient and localPlayer, but not the others (including the one regarding authority.) On the server, the "Network Information" for the client-spawned players says yes to everything but localPlayer.
After working on this for a week, thought I'd reach out to the community. Thanks in advance, and happy holidays.
Answer by OmegaDude · Dec 23, 2015 at 02:11 PM
Solved my own problem: A not-so-obvious detail about NetworkIdentities is that any NetworkIdentity on a player object has to have its "Local Player Authority" tag checked in order to work as expected.
Your answer
Follow this Question
Related Questions
How to make multiplayer editor/race 0 Answers
HLAPI: How to spawn players from preGameScene 1 Answer
player Spawning Error on Photon (PhotonNetwork.Instantiate) 1 Answer
unity game 1 Answer