private IEnumerator PlayerDeath() { activeState = GameController.States.death; mainCamera.GetComponent <CameraFollow>().m_Player = mainCamera.transform; Transform t = player.transform; Instantiate(puffPrefab, t.position, Quaternion.identity); Destroy(player.gameObject); if (stateData.Health > 0) { yield return(new WaitForSeconds(3)); player = Instantiate(playerPrefab); player.GetComponent <Transform>().position = playerSpawn.position; mainCamera.GetComponent <CameraFollow>().m_Player = player.transform; activeState = GameController.States.running; } else { gameOverPanel.gameObject.SetActive(true); Debug.Log("GameRestart after Player Death"); yield return(GameRestart(2, currentLevel, "PlayerDeath")); } }
// Use this for initialization void Start() { dude = FindObjectOfType <Dude2D>(); dudeRenderer = dude.GetComponent <SpriteRenderer>(); cam = GetComponent <Camera>(); cam.aspect = 16f / 9f; }