Melee combat collision does not work

I have made a collision box for detecting hit and applying damage, but it did not work as intended.
The player character is able to pick up a weapon and swing it, and as the weapon’s collision box hits another character, it should cause damage. However, it only works when the player character stand close to the enemy character and swinging towards the opposite direction of the enemy character. It’s a top-down action game and the player character will always facing the cursor location.

Here are the codes for the melee weapon:

AItem::AItem()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	Active = true;
	Root = CreateAbstractDefaultSubobject<USceneComponent>(TEXT("Root"));
	SetRootComponent(Root);
	ObjectMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("ObjectMesh"));
	ObjectMesh->SetupAttachment(Root);
	DamageBox = CreateDefaultSubobject<UBoxComponent>(TEXT("DamageBox"));
	DamageBox->SetupAttachment(ObjectMesh);
}

// Called when the game starts or when spawned
void AItem::BeginPlay()
{
	Super::BeginPlay();
	
	//ObjectMesh->OnComponentHit.AddDynamic(this, &AItem::OnHit);
	DamageBox->OnComponentBeginOverlap.AddDynamic(this, &AItem::OnHit);
	IsAttacking = false;
}

// Called every frame
void AItem::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

void AItem::Interacted()
{
	Active = false;
	//SetActorHiddenInGame(true);
}

bool AItem::GetActive()
{
	return Active;
}

void AItem::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& Hit)
{
	APawn* PlayerPawn = GetWorld()->GetFirstPlayerController()->GetPawn();
	SetOwner(PlayerPawn);
	if (PlayerPawn == nullptr) return;
	auto MyOwnerInstigator = PlayerPawn->GetInstigatorController();
	auto DamageTypeClass = UDamageType::StaticClass();
	if (!OtherActor->ActorHasTag(FName("Pawns"))) return;
	/*UE_LOG(LogTemp, Warning, TEXT("Component Hit..."));*/
	if (OtherActor && OtherActor != this && OtherActor != PlayerPawn && IsAttacking == true)
	{
		UE_LOG(LogTemp, Warning, TEXT("Attacking since it is true"));
		UGameplayStatics::ApplyDamage(OtherActor, Damage, MyOwnerInstigator, PlayerPawn, DamageTypeClass);
	}
	
}

Many thanks!