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