public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RtsPlayer rtsPlayer = conn.identity.GetComponent <RtsPlayer>(); rtsPlayer.SetTeamColor(new Color( Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f) )); var spawnedPlayerTransform = conn.identity.transform; // create new game object using the spawnable prefab (prefab must be set it Netowrk Manager // from Mirror as well GameObject unitSpawnerInstance = Instantiate( unitSpawnerPrefab, spawnedPlayerTransform.position, spawnedPlayerTransform.rotation ); // spawn on server using and assign which user this player is for ß(conn) NetworkServer.Spawn(unitSpawnerInstance, conn); }
public override void OnStartServer() { RtsPlayer player = connectionToClient.identity.GetComponent <RtsPlayer>(); teamColor = player.GetTeamColor(); }