[4.7] Begin Overlap/End Overlap firing

Hi everyone,

I have a custom actor that I am wanting to interact with when I am next to it, like for a door. I created an overlay sphere component but both my begin and end overlap functions are being fired off at the same time, and when I exit the overlay just my end overlap function fires. I set them all up initially in C++; I did play around with them in the blueprints but I haven’t had any luck. Am I missing something? Here is the code I am using in my constructor to set everything up and the parent class of my object is an actor:

//Create RootComponent
	sceneComponent = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("SceneComponent"));
	RootComponent = sceneComponent;

	overlaySphereComponent = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("OverlaySphereComponent"));
	overlaySphereComponent->AttachParent = RootComponent;
	overlaySphereComponent->SetCollisionResponseToChannel(ECC_Pawn, ECollisionResponse::ECR_Overlap);

	overlaySphereComponent->OnComponentBeginOverlap.AddDynamic(this, &ABaseInteractObject::OnWorldOverlapBegin);
	overlaySphereComponent->OnComponentEndOverlap.AddDynamic(this, &ABaseInteractObject::OnWorldOverlapEnd);

Thanks for everyone’s help!

Bump. Still having issues with this.


So it turns out there is a difference between Character and Pawn/Actor that is causing this. I tested it on one of my custom character classes and it fired properly, but not when the parent class is a pawn/actor. That makes me think that it is something within the actor vs character or how the root component is setup as I am creating the root component myself for this actor.

Once we can nail down what exactly it is, we can decide on the final answer.

Hello. Do you have any progress on this? I have the same problem and can not fix it, although everything looks fine.

I typed your code in (I’m in 4.8) and I had problems too.

First, your line 'SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore) makes it so that none of the overlaps fire (which makes sense according to the documentation).

OnWorldOverlapBegin works as I expected: fires when you’re inside the volume, doesn’t fire when you’re outside.

Error: OnWorldOverlapEnd fires exactly as OnWorldOverlapBegins. Debugging the source I see it’s because my character doesn’t have collision turned on. void UPrimitiveComponent::UpdateOverlaps(…) calls EndComponentOverlap on any objects that don’t have collision enabled on their ‘UPrimitiveComponent::BodyInstance’. However OnWorldOverlapBegins doesn’t care about this, so you’re basically seeing it begin and instantly end the overlap every frame. When I turned collision to ‘QueryOnly’ on my character OnWorldOverlapEnd started firing as expected: when you leave the trigger volume.

Seems like a bug in the source to me.

1 Like

Check that your object triggering the overlaps has ‘QueryOnly’ or ‘Collision Enabled (Query and Physics)’

I typed your exact code in and had the same thing happened.

As an aside, note that your line ‘overlaySphereComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);’ makes none of the overlaps fire (as the documentation on that would indicate).

I debugged the source and found a problem dealing with the overlaps firing incorrectly:

UPrimitiveComponent::UpdateOverlaps checks to see if the object causing the overlap has collisions enabled. If it doesn’t, it calls EndComponentOverlap on all overlaps it has. Because the code that checks for BeginOverlap doesn’t care about this, it just ckecks if ‘World Dynamic’ is set to ‘block’, you’re seeing begin trigger, then immediately end triggers; and this repeats every frame. When I gave my actor a collision of ‘QueryOnly’, then all the calls started firing as normal.

The lack of warnings on this whole system is pitiful and why you see so many questions about it.

The whole overlap system needs a lot more warnings IMO.

I posted an answer on this. Check if it solves your issue, and if not, perhaps we can narrow it down more.

Hey 5Kwatts-

I tired your code in 4.8.3 and 4.9.1 in a third person template project. Adding an instance of the class to the level I was able to step inside the sphere component and only see the BeginOverlap tirgger once. The EndOverlap did not trigger until I stepped out of the sphere at which point it triggered once as well. Is there any other setup needed to reproduce this in a new project or have I missed something in my current setup?


The way I reproduced his exact results was to have an actor/Pawn/Character with collisions turned completely off doing the overlaps. Apparently BeginOverlap doesn’t care the actor doesn’t have collisions, but EndOverlap does creating an infinite loop of begin, end, begin, end, etc.

When I turn off my character’s collision the overlap events no longer trigger. Could you send me a sample project where the overlap events are being continuously triggered?

Set ‘Collision Presets’ to ‘Custom’. Set ‘Collision Enabled’ to ‘Physics Only (No Query Collision)’. ‘Object Type’ doesn’t matter but I have it at ‘PhysicsBody’. Then make sure ‘WorldDynamic’ is set to Block.

The code that checks for BeginOverlap just checks for ‘WorldDynamic’ is set to ‘Block’. The EndOverlap checks for Collision to be set to ‘Query Only’ or ‘Collision Enabled (Query and Physics)’ (because otherwise CollisionEnabled is set to false). Consequently every frame you’re in range, you BeginOverlap and EndOverlap and loops forever. Seems like a bug to me. The conditions that send you into that state should be false to release you from that state.

UPrimitiveComponent::UpdateOverlaps checks to see if the object causing the overlap has collisions enabled (as in 'query only or query and physics). If it doesn’t, it calls EndComponentOverlap on all overlaps it has.

Hey everyone!

Thanks for all pitching in. My issue on this I think was that I didn’t have it setup in a child instance of a base object that had that events setup. I tested my above code on a base interact object blueprint of mine and it fired with intended behavior. I reviewed my child source and created the constructor so it would call super properly and deleted my old child blueprint and made a new one and it fired with intended purpose.

I see that mentioned about checking if your character has the correct options in query/physics selected but I didn’t have to do that to fix it. I may have also just randomly stumbled across on how mine is working. About 2/3 days ago I was able to get it working with intended behavior.