/// <summary> /// Spawn player in the set player /// spawn data. /// </summary> public void SpawnPlayer() { // ensure at least one active spawn is set when loading the scene. if (playerSpawnData.activeSpawn.name == "" || playerSpawnData.activeSpawn.name == null) { playerSpawnData.SetActiveSpawn(0); } // move player at the spawn location. Transform spawnPosition = GameObject.Find(playerSpawnData.activeSpawn.gameObjectName).GetComponent <Transform>(); Player.instance.gameObject.transform.position = spawnPosition.position; Player.instance.playerController.SetOrientation(playerSpawnData.activeSpawn.orientation); }
/// <summary> /// Trigger event. /// </summary> /// <returns>IEnumerator public override IEnumerator TriggerEvent() { canBeTriggered = false; GameManager.instance.overWorldUI.UICover.FadeIn(); Player.instance.playerUI.iconWrapper.Hide(); Player.instance.playerController.SetPlayerInEventMode(); // set which spawn data will be used in the next scene. levelSpawnData.SetActiveSpawn(spawnToUse); _audio.PlaySound(0); // decrease level music. StartCoroutine(GameManager.instance.levelMusicManager.audio.FadeOutSongRoutine()); yield return(new WaitForSeconds(2f)); // load new scene. canBeTriggered = true; SceneManager.LoadScene(sceneToLoadName); _event = null; }