// Decreases lives and checks for death private void HandleLives() { LivesManager lv = FindObjectOfType <LivesManager>(); lv.RemoveLife(); if (lv.GetLives() <= 0) { // Game over SceneManager.LoadScene(1); RpcGameOver(); } }
void OnCollisionEnter2D(Collision2D Col) { if (Col.gameObject.CompareTag("Enemy")) { Destroy(Col.gameObject); LM.DecrementLives(); PlayerAnimator.Play("Hit"); if (LM.GetLives() == 0) { GameObject GOScreen = Instantiate(GameoverPrefab, Vector3.zero, Quaternion.identity); GOScreen.transform.SetParent(GameObject.Find("Canvas").transform, false); gameObject.SetActive(false); } } }