Multiplayer: 4 players, each player spawning less amount of other players.
I'm cloning a GitHub repo i got from youtube https://github.com/DapperDino/Mirror-Multiplayer-Tutorials
.
Players counter does not work when using Server Only mode because players are added on OnStartClient(). The players counter has role to define which player is the room master and the players counter deciding is the game can be started or not by controlling start button. Then I made few changes so players counter work on Server Only mode.
.
But I'm facing problem at spawning players on Server Only mode. So one player spawning all other players, One other player spawning 3 players, One other spawn 2 players, and one other only spawn it self. Please see image down below.
.
.
[Server]
public void SpawnPlayer(NetworkConnection conn)
{
Transform spawnPoint = spawnPoints.ElementAtOrDefault(nextIndex);
if (spawnPoint == null)
{
Debug.LogError($"Missing spawn point for player {nextIndex}");
return;
}
GameObject playerInstance = Instantiate(playerPrefab, spawnPoints[nextIndex].position, spawnPoints[nextIndex].rotation);
NetworkServer.Spawn(playerInstance, conn);
nextIndex++;
}
.
The server spawning all players all the time with no problem. But the players always spawning 4-3-2-1 amount of player. The number of players displayed by other players is also not affected by the order in which he joins the lobby.
.
The game works fine on Host(server+client) mode. All players spawned all other players.
.