Character overlap box with other actors

I want to attach a box component to the front of my character that calls a function when it overlaps with a custom interactable class derived from actor. How would I go about doing this? So far I have this in my character cpp file…

InteractableCollisionShape = CreateDefaultSubobject<UBoxComponent>(TEXT("interactable collision box"));
InteractableCollisionShape->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
InteractableCollisionShape->SetCollisionResponseToAllChannels(ECR_Ignore);
InteractableCollisionShape->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
InteractableCollisionShape->bGenerateOverlapEvents = true;
InteractableCollisionShape->OnComponentBeginOverlap.AddDynamic(this, &AMyCharacter::onInteractableHit);
InteractableCollisionShape->SetupAttachment(GetMesh());

This is stuff I’ve gathered from different tutorials, but its mostly just me blindly throwing darts at a dart board. I dont know what I need to get rid of or change. Any help would be greatly appreciated.

(Its important the collision box is attached to the character and not the object so that the function it is only called when the player is facing that object, not just in its area. Also a line trace doesn’t work because its too finicky with different sized and shaped objects.)

Hi @FishMob , can you describe the behavior you are seeing versus what you are expecting? I dont see anything inherently wrong with the code you posted. The other actor needs to have "generate iverlap events " set to true as well.

Note that any overlap will throw the OnActorBeginOverlap event, so you will have to use the halfspace test between your character orientation and the initial contact to determine if you are looking at the object.