- Home /
Question by
CarterG81 · Jul 03, 2015 at 06:10 PM ·
multiplayerunity5unity multiplayer
[UNET] PlayerPrefab successfully spawns on Server, but Clients only see their own playerPrefab.
Whenever a client connects, their playerPrefab is sucessfully added to the Server. So if I have 5 players connected to one server, it will show 5 players on the Server/Host.
However, each Client only sees their own character and none other. So all 5 players would only see 1 player- themselves, unless one is Host(Server+Client).
Client movement is synced with server, so Server seems to be working as it should. Clients are not. They sync with server, but I only assume the Server never tells the Client to create all the other player's playerPrefabs.
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) //,
{
GameObject player = (GameObject)Instantiate(playerPrefab, Vector3.zero, Quaternion.identity); //Create the playerPrefab
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId); //Spawn on Server & Ready.
//NetworkServer.ReplacePlayerForConnection(conn, player, playerControllerId);
}
public void SelectCharacterButton(string name)
{
//SpawnPlayer on Server
ClientScene.AddPlayer(0); //Sends the message to the server asking to spawn playerobject for this client.
//ClientScene.AddPlayer(GameNetworkManager.singleton.client.connection, 0); //Sends the message to the server asking to spawn playerobject for this client.
}
public override void OnStartClient(NetworkClient client)
{
base.OnStartClient(client);
}
Comment