void OnCollisionEnter2D(Collision2D other) { Ruby_Controller player = other.gameObject.GetComponent <Ruby_Controller>(); if (player != null) { player.ChangeHealth(-1); } }
void OnTriggerStay2D(Collider2D other) { Ruby_Controller controller = other.GetComponent <Ruby_Controller>(); if (controller != null) { controller.ChangeHealth(-1); } }
void OnTriggerEnter2D(Collider2D other) { Debug.Log("Object that entered trigger: " + other); Ruby_Controller controller = other.GetComponent <Ruby_Controller>(); if (controller != null) { if (controller.Health < controller.Max_Health) { controller.ChangeHealth(1); Destroy(gameObject); controller.Play_Sound(Collected_Clip); } } }