Download

UBoxComponent Hit Event

I have character with sword as one mesh. In sword i have bone with socket.

Inside character i create UBoxComponent like this:

WeaponHitBox = CreateDefaultSubobject<UBoxComponent>(TEXT("WeaponHitBox"));
WeaponHitBox->SetCollisionObjectType(ECC_GameTraceChannel3); //Special TraceChannel for melee.
WeaponHitBox->SetCollisionResponseToAllChannels(ECR_Ignore);
WeaponHitBox->SetupAttachment(GetMesh(), TEXT("HitBoxSocket"));
WeaponHitBox->OnComponentHit.AddDynamic(this, &ATwoPlayer::Server_OnHitBoxHit);

When left mouse button clicked, i run animation and WeaponHitBox moves with this animation.
Also when animation starts, i enable collision for WeaponHitBox like this:

WeaponHitBox->SetCollisionResponseToChannel(ECC_Pawn, ECR_Block);

So i want to “Hit” mesh of other character.

Mesh setup:
GetMesh()->SetCollisionResponseToChannel(ECC_GameTraceChannel3, ECR_Block);

So Mesh is blocking GameTraceChannel3, WeaponHitBox blocking Pawn and WeaponHitBox’s object type is GameTraceChannel3.

For some reason i can’t get any hit events. Any ideas why? My setup is wrong?

In the relevant Blueprints, do you have Generate Overlap Events checked on all the components you mentioned? There’s also a difference between Hit and Overlap. Your box might not hit the character mesh because it’s blocked by that character’s capsule before it can even get to the mesh.

Now i have
GetMesh()->SetGenerateOverlapEvents(true);
This setup works perfectly if i use OnComponentOverlap.

I tried to SetGenerateOverlapEvents to WeaponHitBox too, but got same result.

Also caplsule ignoring GameTraceChannel3

In same project i have other actor with same setup but with ProjectileMovementComponent and everything works. But when i do this in my character…