void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player1")) { player1Health.TakeDamage(dmg); //col.SendMessageUpwards("TakeDamage", dmg); } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Player1")) { player1Health.TakeDamage(dmg); Collider2D collider = gameObject.GetComponentInParent(typeof(Collider2D)) as Collider2D; if (collider != null) { collider.enabled = false; } Destroy(this.gameObject); } }