Component Overlap Event not firing

I’m working with the first person shooter template program, and trying to modify the projectiles to pass through each other. I don’t want them to be immune to colliding with projectiles in general, but to never interact with the owner or any other projectiles from the same source.

The plan for this was to change it to overlap and then use logic to determine if the overlap should do anything or not. The problem is that I can’t get the beginoverlap event to fire at all.

Right now I’m trying to set up the event with:

CollisionComp->OnComponentBeginOverlap.AddDynamic(this, &AFirstProjectile::OnOverlapBegin);
CollisionComp->OnComponentEndOverlap.AddDynamic(this, &AFirstProjectile::OnOverlapEnd);

In the constructor. And OnOverlapBegin is:

void AFirstProjectile::OnOverlapBegin(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
	Destroy();
}

(OnOverlapEnd is empty). This is just a quick example to make sure that the event was firing… and it’s not. I can shoot the projectiles and cause them to overlap, and they’re never destroyed, and the breakpoint I set in the C++ code is never hit.

The collision for the projectiles are:

This definitely made a change in behavior, as they will overlap in play now (ex http://i.imgur.com/HnWP11P.png ) instead of bouncing off each other as in the default template.

I also tried making a blueprint to accomplish roughly the same thing, which is not being fired either. I don’t know for certain that I set it up correctly, however, as I’m almost exclusively working with C++ for this. My attempt: http://i.imgur.com/uYRtf1I.png

The only info I’ve found on this from searching the web is to ensure that ‘Generate Overlap Events’ is checked in the collision settings, and it is. There are no compiler errors when I attempt to build/run this, the event is just never fired.

I’m still new to UE4 so it’s very likely I’m missing something obvious. What can I do to make this event fire properly?

I was having a similar issue. Using OnComponentHit instead of OnOverlapBegin worked in my case.

For me having my binding function in begin play fixed the issue

GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &ATheTowerCharacter::OnOverlapBegin);

I also made sure both components had generate overlap events set to true.

Yep that fixed it for me also!

Why it didnt work in the constructor though?

Not sure why it isn’t working in constructors. It doesn’t seem consistent
Using 4.19 Preview 5
With an Actor that only has a UPaperSpriteComponent it won’t fire the event if it were registered in the constructor
However, if I had a boxcollision or any other collision component it will fired if registered in the constructor.

I too had to put the AddDynamic line in BeginPlay

Edit:
My guess is, the UPaperSpriteComponent does some late initialization because it has to calculate bounds and make the collisions accordingly depending on the applied texture, which it may do in it’s constructor. There may be sort of a race condition where the order of initialization or constructors being called isn’t guaranteed and causes the AddDynamic to no longer be valid.

It works if I put it in PreInitializeComponents, InitializeComponents, or PostInitializeComponents (and may work in other stages of the lifecycle)

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/27833-beginplay-postinitcomponents-for-a-component