/// <summary> /// This method is called whenever another object enters a trigger collider /// attached to the defined object. /// </summary> /// <param name="other"></param> void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Coin")) { other.gameObject.SetActive(false); coins += 1; //send new val to playerprefs PlayerPrefs.SetInt("coins", coins); CoinCollect.Play(); Score_Update(); } if (one_smack == false) { if (other.gameObject.CompareTag("FallKill")) { one_smack = true; if (lives.lives >= 0) { lives.Damage(); } } } if (other.gameObject.CompareTag("Goal")) { SceneManager.LoadScene(2); } }