Begin/End Overlap same time

I have a USphereComponent for an enemy character. When the player walks into the sphere, I want it to trigger the enemy to start attacking, etc.

The problem I’m having is when my character walks into the sphere, the OnComponentBeginOverlap is called immediately followed by OnComponentEndOverlap

I setup the collision to only be on pawn, and put special code it to see if the overlap is with the character. It still calls both.

My code looks like this

In enemy character constructor

mActorRadiusTrigger->OnComponentBeginOverlap.AddDynamic(this, &AEnemyCharacter::TriggerEnter);
mActorRadiusTrigger->OnComponentEndOverlap.AddDynamic(this, &AEnemyCharacter::TriggerExit);

My trigger functions.

void AEnemyCharacter::TriggerEnter(AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (Other == this)
		return;

	AMyCharacter *character = Cast<AMyCharacter>(Other);
	if (character)
	{
		StartTracking();
	}
}

void AEnemyCharacter::TriggerExit(class AActor* Other, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
	if (Other == this)
		return;

	AMyCharacter *character = Cast<AMyCharacter>(Other);
	if (character)
	{
		StopTracking();
	}
}

When I step into the sphere it calls StartTracking() then StopTracking() in the same frame.

If I then back up, it calls StopTracking() a second time.

StartTracking() and StopTracking() currently do nothing, so it’s not like the enemy starts moving and moves out of range or something like that.

Do you have physic substepping enabled and moving the actor very fast ?

Is collision for the object activated ?

If you have both collison response and overlap events activated, perhaps you get both start- and endoverlap, because the collision response immediately forces the shapes to be collision-free.

Just ideas…