void Start() { Events.OnMusicChange("crowds"); Levels.LevelData levelData = Data.Instance.GetComponent <Levels>().GetCurrentLevelData(); targetSpeed = levelData.speed; acceleration = levelData.acceleration; totalPlayers = 1; if (ForceMultiplayer || Data.Instance.userData.mode == UserData.modes.MULTIPLAYER) { totalPlayers = Data.Instance.multiplayerData.players.Count; } LaneSeparation = Data.Instance.gameSettings.LaneSeparation; float offsetY = (totalPlayers - 1) * (LaneSeparation / 2); for (int a = 0; a < totalPlayers; a++) { int id = 1; if (ForceMultiplayer || Data.Instance.userData.mode == UserData.modes.MULTIPLAYER) { id = Data.Instance.multiplayerData.players[a].playerID; } GameObject newContainer = Instantiate(container) as GameObject; newContainer.GetComponent <GameCamera>().id = a + 1; newContainer.GetComponent <GameCamera>()._y = a * -LaneSeparation; containers.Add(newContainer); newContainer.transform.SetParent(gameCanvas.transform); Vector3 pos = new Vector3(0, offsetY, 0); newContainer.transform.localPosition = pos; newContainer.transform.localScale = Vector3.one; Lane newLane = Instantiate(lane) as Lane; newLane.transform.SetParent(newContainer.transform); lanes.Add(newLane); newLane.GetComponent <Transform>().localPosition = new Vector2(0, a * -LaneSeparation); newLane.Init(newContainer.GetComponent <GameCamera>()); Player newPlayer = Instantiate(player) as Player; newPlayer.SetColor(Data.Instance.colors[id - 1]); newPlayer.transform.SetParent(newContainer.transform); players.Add(newPlayer); newPlayer.GetComponent <Transform>().localPosition = new Vector2(-18f, a * -LaneSeparation); newPlayer.id = id; newPlayer.Init(newContainer.GetComponent <GameCamera>()); } //scaleFactor = containers[0].GetComponentInParent<Canvas>().scaleFactor; Events.StartGame += StartGame; Events.OnAvatarDie += OnAvatarDie; Events.OnAvatarWinLap += OnAvatarWinLap; Events.OnTimeOver += OnTimeOver; Events.GameOver += GameOver; LaneSeparation /= scaleFactor; if (!ForceMultiplayer) { Invoke("OnPowerUp", Random.Range(8, 12)); } }