Auto Melee Targeting when attackin

Yo!

I would like to make my player character face towards the nearest enemy that is in the general direction of the player character when in melee range when doing a melee attack. Similar to God Of War 5, or Saints Row 4 melee combat.

I have tried using a raycast and rotators to pick an actor in the general direction and face it, but it isnt as smooth or dynamic and usually misses the enemy.

Im tryna make a superhero similar to project awakened and the other superpowers are going well but the melee combat feels horrible even tho its just one button.

Thnx in advance

On Melee Attack Overlap Sphere to get Potential targets in desired Range (Sphere Radius)

Filter out Potential targets that are not in certain Angle in front of you or where your Input Direction goes to or any other filtering you want to do (Math)

Get the Closest one (Math)

Interpolate towards Target (you might want to have a little offset from him too) or do a simple forward attack if no closeby Target was found.

Good Luck