2D Sword Collision: How to?

Lets say I have a 2D Character with a sword. Lets say we press “spacebar” and the player object plays the “swingSword” animation. How would I detect a hit?

The only thing I can think of is, when the player presses “spacebar” I make a variable true that runs an OnTriggerEnter one time, and if another object triggers the player, we have a hit.

Is there any better way to do this?

Any thoughts on this one?

make a boolean variable name Hit=false, this variable become true when two events happened:
1)press spacebar
2)another object enter the sword trigger collider
else Hit return false