Sword swinging in unity 2d

I have a sword animation and not a separate sword child object . Now how can I check for collision between the player and the enemies

Depending on how complex you need to go …

  • You could just check the distance to enemies and count them as hit when they are too close during a swing.
  • You could place a trigger collider roughly where the sword is and activate it during the swing.
  • You could use a small collider and animate its position during the swing, following the path of the sword.