Working with Collision Layers in Unity

2D Mobile Game

Objective: Create a collision layer so that the sword ignores the player colliders when swing the sword

Now add two new layers player and sword and then select the player layer for player first and then select the sword layer for the hit box sprite inside the player gameobject.

Now go to Edit>Project Settings>Physics 2D and then de-select the sword layer for the player.

This will now allow the sword collider to ignore the player collider and the player can no longer be damaged by the sword swing.