public virtual void OnCollisionEnter2D(Collision2D collision) { GameObject other = collision.gameObject; if (other.name == "player") { PlayerScript playerScript = other.gameObject.GetComponent <PlayerScript>(); playerScript.AddCoins(amount); playerScript.PlaySound(PlayerSounds.COIN_COLLECT); Destroy(this.gameObject); } }