# OnComponentBeginOverlap AddDynamic not working

**URL:** <https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276>\
**Category:** C++\
**Tags:** overlap, unreal-engine, Collision, question\
**Created:** [January 22, 2025, 2:27pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276 "2025-01-22T14:27:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![miguline](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@miguline](https://forums.unrealengine.com/u/miguline)\
**Post date:** [January 22, 2025, 2:27pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/1 "2025-01-22T14:27:20Z")

</div>

So, the same code is working on some assets, collisions are working, cos in blueprint the overlap works, te code on the cpp is:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “Box Collision”)  
BoxComponentToGrabHammer = CreateDefaultSubobject(TEXT(“Collision To Grab”));  
BoxComponentToGrabHammer-\>SetupAttachment(StaticMesh);  
BoxComponentToGrabHammer-\>SetGenerateOverlapEvents(true);  
BoxComponentToGrabHammer-\>OnComponentBeginOverlap.AddDynamic(this, &AHammerC::GrabhammerBeginPlay);

void AHammerC::GrabhammerBeginPlay(UPrimitiveComponent\* OverlappedComponent, AActor\* OtherActor, UPrimitiveComponent\* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)  
{  
UE\_LOG(LogTemp, Warning, TEXT(“GrabHammerOverlap”));  
}

In the past, just deleting the Binaries Intermediate and DerivedDataCache and rebuild worked, but this time it is not

It is not the full code on “GrabhammerBeginPlay()” so is easier to read

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 22, 2025, 2:41pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/2 "2025-01-22T14:41:55Z")

</div>

Hey,

When you say its not working what exactly do you mean?

There are a few options that could be the reason for this not working here:

- Is GrabhammerBeginPlay a UFUNCTION()
- Are the collision settings setup correctly so that this actually get triggered. Looking at the Profile as I see you already set GenerateOverlapEvents to true.

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 22, 2025, 2:43pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/3 "2025-01-22T14:43:06Z")

</div>

If you aren’t familiar with the Collision system this is a great video explaining this - [https://www.youtube.com/watch?v=xIQI6nXFygA](https://www.youtube.com/watch?v=xIQI6nXFygA)

---

<div class="post-metadata">

**Author:** ![miguline](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@miguline](https://forums.unrealengine.com/u/miguline)\
**Post date:** [January 22, 2025, 2:55pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/4 "2025-01-22T14:55:53Z")

</div>

> [@JakeSimpson](#):
>
> UFUNCTION()

Yeah maybe is the “UFUNCTION()” I started some week ago with C++, cos I have been coding in blueprint for 11 years. Thank you so much it was the UFUNCTION the solution, I remember that in the other begin play I put the UFUNCTION().

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 22, 2025, 3:14pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/5 "2025-01-22T15:14:10Z")

</div>

No worries glad to help 😃

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 21, 2025, 3:14pm UTC](https://forums.unrealengine.com/t/oncomponentbeginoverlap-adddynamic-not-working/2297276/6 "2025-02-21T15:14:21Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
