Best Way to Handle Melee Attacks

Just wondering how people might handle melee attacking?

I am making a 2.5D platformer, and my character, throughout the course of the game, will be able to upgrade their weapon.

I’m thinking:

The player has a reference to a Weapon.

The Weapon is a trigger collider which is moved around in front of the player, and is enabled for a few frames when the player hits the attack button.

The Weapon’s OnTriggerEnter checks for any colliders which might be Enemies, and calls their Harm(damage) method.

That seems simple enough, but it feels a little messy to be dealing with the weapon as a (mostly) autonomous entity.

I’d love to hear suggestions from anyone who might have alternatives for dealing with melee attacks.

Makes sense to me, at least for a simple system such as a platformer where you just want attack to hit something close in front of you, without caring about detailed contact info.

I see it as logical for the weapon to be an entity in itself, since it can be independently active/inactive, it can be changed independently, and it is responsible for the process of doing damage. Keeping those processes separate from the other player actions like moving, should help to keep your code clean and clear.