to be honest your initial code looks correct
I tested it myself with a normal sphere component and it works as you would expect
.h:
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "AnswerHubAnswersCharacter.h"
#include "CharacterWithSphere.generated.h"
class USphereComponent;
UCLASS(config = Game)
class ACharacterWithSphere : public AAnswerHubAnswersCharacter
{
GENERATED_BODY()
public:
ACharacterWithSphere();
void BeginPlay() override;
protected:
UFUNCTION()
void OnInteractorBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep,
const FHitResult& SweepResult);
UPROPERTY(VisibleAnywhere)
USphereComponent* SphereComponent;
};
.cpp:
#include "CharacterWithSphere.h"
#include "Components/SphereComponent.h"
ACharacterWithSphere::ACharacterWithSphere()
{
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("USphereComponent"));
SphereComponent->SetupAttachment(RootComponent);
SphereComponent->InitSphereRadius(500.0f);
}
void ACharacterWithSphere::BeginPlay()
{
Super::BeginPlay();
SphereComponent->OnComponentBeginOverlap.AddDynamic(this, &ACharacterWithSphere::OnInteractorBeginOverlap);
}
void ACharacterWithSphere::OnInteractorBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("So Overlappy!"));
}
The only thing i changed is move the registration to the overlap into the BeginPlay
had strange behavior in the past when I had that somewhere else.
So either your UInteractorComponent is doing something strange, or the radius is changed somewhere else.