void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.CompareTag("oof")) { GameObject Player = GameObject.Find("Player"); NextLV NextLV = Player.GetComponent <NextLV>(); NextLV.currenthp = NextLV.currenthp -= 1; NextLV.SpriteSw(); NextLV.SetHealth(NextLV.currenthp); } if (collider.gameObject.CompareTag("winn")) { GameObject Player = GameObject.Find("Player"); NextLV nxtlv = Player.GetComponent <NextLV>(); if (nxtlv.currenthp == 5) { if (trueend == 0) { trueend = 1; } if (trueend == 1) { trueend = 2; } if (trueend == 2) { trueend = 3; } } SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }
void Update() { lvbar.SetHealth(currenthp); if (currenthp == 0) { SceneManager.LoadScene("LoseScene"); } }