void OnTriggerStay2D(Collider2D other) { RubiController controller = other.GetComponent <RubiController>(); if (controller != null) { controller.ChangeHealth(-1); } }
void OnCollisionEnter2D(Collision2D other) { RubiController player = other.gameObject.GetComponent <RubiController>(); if (player != null) { player.ChangeHealth(-1); } }
void OnTriggerEnter2D(Collider2D other) { RubiController controller = other.GetComponent <RubiController>(); if (controller != null) { if (controller.Health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); controller.PlaySound(collectedClip); } } }