# OnComponentBeginOverlap C++

**URL:** <https://forums.unrealengine.com/t/oncomponentbeginoverlap-c/449588>\
**Category:** C++\
**Tags:** overlapping, unreal-engine, UE4, CPP, question\
**Created:** [May 26, 2019, 4:47am UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-c/449588 "2019-05-26T04:47:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![issomsm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@issomsm](https://forums.unrealengine.com/u/issomsm)\
**Post date:** [May 26, 2019, 4:47am UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-c/449588/1 "2019-05-26T04:47:56Z")

</div>

.h

```
UFUNCTION()
void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
USphereComponent * SphereComp;

.cpp

	SphereComp = CreateDefaultSubobject <USphereComponent>(TEXT("SphereComp"));
	SphereComp->SetCollisionProfileName(TEXT("Collision"));
	SphereComp->SetupAttachment(RootComponent);
	SphereComp->OnComponentBeginOverlap.AddDynamic(this, &AArrow::OnOverlapBegin);
}

void AArrow::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("Overlap"));
	}
}

```

Idk why but its not Overlapping.

---

<div class="post-metadata">

**Author:** ![issomsm](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@issomsm](https://forums.unrealengine.com/u/issomsm)\
**Post date:** [May 26, 2019, 5:23pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-c/449588/2 "2019-05-26T17:23:18Z")

</div>

Nvm, I found what was wrong…

For those who are having the same issue:  
If u create the BP based on your c++ code, and then modify later the c++ code, u should re-create the BP file. Seems like that when u create the BP before, on a way it bug and dont compile propely.
