How to make UBoxComponent of sword ignore owner, when it calculates collision

Hello! :slight_smile:
I have class BaseWeapon with its Components (SkeletalMesh and UBoxComponent), which is spawned by WeaponComponent of Character in socket of Character’s hand.
When I walk or attack (simple sword swing animation) UBoxComponent collides with Capsule of its Owning Character and impulses from it collision create a show.
I’ve tried to add Owner and its Capsule to IgnoreActorsWhenMoving, but it didn’t work.

	PrimaryActorTick.bCanEverTick = false;
	WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>("WeaponMesh");
	BladeCollisionComponent = CreateDefaultSubobject<UBoxComponent>(
	BladeCollisionComponent->OnComponentHit.AddDynamic(this, &ABaseWeapon::OnHit);
void ABaseWeapon::OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor,
	UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
	GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White,  GetOwner()->GetName());
	if (AActor* Character = GetOwner(); OtherActor != Character && Character)
		OtherActor->TakeDamage(Damage, FDamageEvent(), nullptr, Character);
		UKismetSystemLibrary::Delay(GetWorld(), 0.5f, LatentActionInfo);

Thank you for your help!

I think the easiest thing would be to create a custom collision channel for either the character or the enemies, and not just use Pawn for all of them, and make the box component ignore the character’s channel.

1 Like

Thank you, I was thinking about it, but also hoped for more elegant solution.