Hitbox Attack System Unity2D
2D Mobile Game
Objective: Create a Hitbox for player attack which will allow the sword to damage the enemies when it hits them
We add a 2d sprite which then will be used to wrap around the sword and move along with its movement, name it Hit_Box for clarity.
Now add a box collider to the created sprite and set the trigger to true so that we can hit the enemies and detect them as well.
Now create a attack animation in which we will make changes to the shape, size and direction of the box collider in hit box to match that of a sword.
And this is the result.