private void OnTriggerEnter2D(Collider2D hit) { PlayerCombat player = hit.GetComponent <PlayerCombat>(); if (player != null) { attackDetails[0] = damage; attackDetails[1] = gameObject.transform.position.x; player.Damage(attackDetails); } Destroy(gameObject); }