Approach to melee attacks


I was wondering which approach is commonly used to damage an enemy.

You can use raycasting and distance as requirements to attack, but you can of course also use a trigger on your weapon model as a solution. Which one is commonly used?

As has been already noted, it depends on how your melee system should work.

You could send a single ray out forward and damage the enemy it hits.
You could send a RayCastAll out for a piercing attack that damages multiple enemies.
You could Cast multiple RaycastAll rays in an arc around your character for a sweeping attack.
You could use an OverlapSphere to hit multiple enemies in a spherical area.
You could give the melee weapon itself a collider trigger and/or rigidbody and if it connects with any enemies while it is swung, damage them.
There are probably other methids, including purely coded ones (without any kind of collision or raycasting), and they can also be combined. I’d say you start with a simple raycast to start things out and work from there. :slight_smile: