private void OnCollisionEnter2D(Collision2D other) { DudeController player = other.gameObject.GetComponent <DudeController>(); if (player != null) { player.ChangeHealth(-1); } }
void OnCollisionEnter2D(Collision2D other) { DudeController player = other.gameObject.GetComponent <DudeController>(); int bonusDamage = LevelManager.difficulty; if (player != null) { player.ChangeHealth(-1 - bonusDamage); } Destroy(gameObject); }
private void OnTriggerStay2D(Collider2D other) { DudeController controller = other.GetComponent <DudeController>(); if (controller != null) { if (DudeController.currentHealth < DudeController.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); controller.PlaySound(collectedClip); } } }