public void OnPlayerJoined(PlayerInput player) { player.GetComponent <Player>().Init(); LobbyPlayerController pc = Instantiate(lobbyPlayerControllerPrefab, spawnPoints[GameManager.Players.Length]).GetComponent <LobbyPlayerController>(); ToggleSwitch readySwitch = Instantiate(readyTogglePrefab, contentHolder).GetComponent <ToggleSwitch>(); //_readySwitches.Add(readySwitch); pc.Initiate(player.GetComponent <Player>(), this, Instantiate(outfitListPrefab, contentHolder).GetComponent <UIList>(), readySwitch); mainCamera.AddTarget(pc.transform); Debug.Log(player.user.index + " joined"); }
public void AddPlayer(int playerNum) { players.Add(new Player(playerNum, playerHealth, playerSpeed)); players[players.Count - 1].playerObject = (GameObject)Instantiate(playerCharacter, playerSpawnLocations[players.Count - 1], Quaternion.identity); players[players.Count - 1].playerObject.GetComponent <PlayerMove>().playerNumber = playerNum; players[players.Count - 1].playerObject.GetComponent <PlayerMove>().SetSpeed(playerSpeed); players[players.Count - 1].playerObject.GetComponent <PlayerMove>().slowMoveSpeed = playerSlowSpeed; players[players.Count - 1].playerObject.GetComponent <PlayerMove>().normalMoveSpeed = playerSpeed; players[players.Count - 1].playerObject.GetComponent <PlayerShoot>().playerNumber = playerNum; players[players.Count - 1].playerObject.GetComponent <PlayerInteraction>().playerNumber = playerNum; players[players.Count - 1].playerObject.GetComponent <PlayerHealth>().maxHealth = playerHealth; //players[players.Count - 1].playerObject.GetComponent<SetHatColour>().hat.color = Color.blue; Material[] playerMaterials = players[players.Count - 1].playerObject.GetComponent <SetHatColour>().hat.materials; playerMaterials[1] = playerColours[players.Count - 1]; players[players.Count - 1].playerObject.GetComponent <SetHatColour>().hat.materials = playerMaterials; cam.AddTarget(players[players.Count - 1].playerObject.transform); //////////////move this }
private void OnEnable() { cam.AddTarget(transform); StartCoroutine(PlayRandomSound()); }