- Home /
IS it possible to have delayed player spawning after server connection? (UNet)
I feel like this is a stupidly simple question, but ive searched for 2 days now and found nothing just to perform this simple task.
Overview of what I'm trying to do: I want both players to connect, select character and THEN SPAWN THE CHARACTERS. I do not want the player character to be spawned when the player connects. This seems extremely simple but due to everything beind inside a magic black box for server/client callbacks when players connect this just isn't happening.
Here's what I've tried so far:
public override void OnServerConnect(NetworkConnection conn)
{
Debug.Log("Player " + iNumActivePlayers + " connected from " + conn.hostId);
connections.Add(conn);
base.OnServerConnect(conn);
}
store the connections in a list of connections when someone connects. then when i click a button on the HOST I want all clients to spawn their own characters. and have them play out as if they spawned instantly on connection
Is the only way to do this by adding another game object to the scene, give it a new scripts that inherits networkbehaviour and have that call ClientScene.AddPlayer() ? via [Command] and [RpcClient] functions?
I feel like i'm not understanding something about this behavior or i'm not overriding functions properly.
Any help would be appreciated literally every single tutorial for this is barebones " spawn the player instantly when people connects" and every other question ive seen on this still is instant spawning.
Answer by Halfbiscuit · Mar 24, 2017 at 10:52 AM
On our project we have "Dummy" player objects which store basic data about the connected clients. These are then spawned on connection. Then later on we spawn the actual player character using this data.
$$anonymous$$akes sense. But say my actual player has like 7 scripts that need initialization and a certain mesh hierarchy. and the dummy is just an empty gameobject with some script holding logic with a network identity attached as well. how would i go about replacing the actual "player" in reference to the network manager's "player" for the character, such that it operates the same, i.e: both players see it but only the respective clients control it?
We are using a do$$anonymous$$ant server model so we send inputs across via command functions on the dummy player and move the 'actual player' accordingly on the server. I believe there is a way to give specific client authority on non player network objects (on the network identity object?),which may get you closer to your goal.
Your answer
Follow this Question
Related Questions
How to watch in client applications what it is happening in the server one? 0 Answers
What is the CCU of the default Unity Networking? 1 Answer
Only host client is able to spawn objects 0 Answers
Since switching to using offline & online scenes in the NetworkManager, Clients will not sync (UNET) 0 Answers
Network Game Player reference 0 Answers