OnBeginOverlap Issues.

Hello Everyone I am creating a collision sphere attached to my actor to act as a proximity mechanic I have created the component and delegates as shown bellow but the overlap calls only get called when I am looking at a viewport of a blueprint based on the class. In game they do not work (nor does the collision sphere show even though I have show collisions on) The sphere sets up and can be edited in the Blueprint (EditAnywhere is temporary and will be removed later It was just my debugging.) I also get my UE_Logs from the constructor. Just nothing shows up in game. Any thoughts on what I have don wrong?


	void OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);
	void OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);


// Sets default values
ACPP_Bot::ACPP_Bot(const FObjectInitializer& ObjectInitializer)
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	AIControllerClass = ACPP_AIController::StaticClass();
	PrimaryActorTick.bCanEverTick = true;

	AvoidanceOverlap = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("AvoidanceOverlap"));
	AvoidanceOverlap->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);

	/*Setup OnCollision Delegate*/
	AvoidanceOverlap->OnComponentBeginOverlap.AddDynamic(this, &ACPP_Bot::OnBeginOverlap);
	UE_LOG(LogTemp, Log, TEXT("Overlap Delegate Assigned"));
	AvoidanceOverlap->OnComponentEndOverlap.AddDynamic(this, &ACPP_Bot::OnEndOverlap);
	UE_LOG(LogTemp, Log, TEXT("Overlap Ended Delegate Assigned"));

Overlap Overrides

void ACPP_Bot::OnBeginOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
	UE_LOG(LogTemp, Log, TEXT("Overlap Detected"));
	if (GetController()->StaticClass() == ACPP_AIController::StaticClass())

void ACPP_Bot::OnEndOverlap(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
	UE_LOG(LogTemp, Log, TEXT("Overlap Ended"));
	if (GetController()->StaticClass() == ACPP_AIController::StaticClass())

Just to check, BOTH actors your colliding against each other have “Generate Overlap Events” checked ON right? Overlaps require both actors to have this setting on.

In the constructor, you’re forgetting to attach the sphere to your root or other component.


Ahh you’r right. It was the attaching. How did I forget that…

Happens. :smiley: Hope it’s smooth sailing from there.