void OnTriggerExit2D(Collider2D col) { HeartWeight w = col.gameObject.GetComponent <HeartWeight>(); if (w != null) { currentWeight -= w.weight; } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("heartPiece")) { HeartWeight w = other.gameObject.GetComponent <HeartWeight>(); if (w != null) { currentWeight += w.weight; } } }