void OnTriggerStay2D(Collider2D other) { RubyControl control = other.GetComponent <RubyControl>(); if (control != null) { control.ChangeHealth(-1); } }
void OnCollisionEnter2D(Collision2D other) { RubyControl player = other.gameObject.GetComponent <RubyControl>(); if (player != null) { player.ChangeHealth(-1); } }
void OnTriggerStay2D(Collider2D other) { //Debug.Log("El objeto hizo collision con el trigger: " + other); RubyControl controller = other.GetComponent <RubyControl>(); if (controller != null) { if (controller.health < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); } } }