OnComponentBeginOverlap fires while character is running

What I’m trying to accomplish

Let me first start off by apologizing for this long winded post.

I’m trying to create an actor that will damage other pawns when it overlaps them. I want it as a separate actor blueprint so I can create other blueprints from it and change the effects, radius size etc. This way you could add an effect to the pawn that would damage any character within a small radius or perhaps add another effect on top of that one that would pull characters closer to the pawn. The reason for this is to have the effects be modular so I can add as many as I want (within reason) and swap them whenever I want. Unless there is a better way to go about doing this, here’s what I’m doing.

Setup

I’ve create a Blueprint called BP_TestActor. Within BP_TestActor I’ve added a Sphere Component and setup the sphere to only overlap pawns as well as not be hidden in game (so I can visualize the overlaps). The BP_TestActor has an event of OnComponentBeginOverlap(Sphere1) enabled. From this I hooked up an authority switch (which works fine) then I cast the overlapping actor into MyCharacter and then adjust that characters HitPoints.

In myCharacter Blueprint I’ve setup a Begin Play Event which hooks up to a for loop and loops X times which in turn spawns BP_TestActor and adds it to an array. Then I have another for loop setup to loop through each spawned actor and attach it to the myCharacter Blueprint instance. This seems to work flawlessly as I see each character that is spawned (on the server) with the sphere component on them. I also have a tick event updating text above the characters head with their current hit points just as a visual reference so I know the moment the hit points change.

The Issue

When I run around on screen with myCharacter the OnComponentBeginOverlap(Sphere1) event keeps firing. As soon as I stop running the overlap stops firing. If I walk into another characters sphere then their sphere fires ones and adjust HP correctly. This does not seem to be related to any of the networking or server/client side code as I’ve tested this in single player and get the same results. It seems to have to do with attaching the BP_TestActor to the myCharacter. If I just spawn the BP_TestActor and move it to the characters location every tick, it works as you’d expect and does not fire as the character is running because they’ve only overlapped it once.

Simple way of replicating the problem

You can replicate this by creating a blueprint of an actor and adding a sphere component to it. On the same blueprint add and event of onComponentBeginOverlap for the sphere. Attach print string to the overlap event just to see when it fires. In the blueprint of the character that is being used, add an Event BeginPlay and hook that up to spawn actor from class. Specify the first class that you created and make a transform for it (it doesn’t matter where it spawns). Also make sure to set the spawn actor to snap to target. Finally hook that node to a node for attach actor to actor. Specify the target as the blueprint you created and the In Parent Actor as self. Click play and start running with the character. You should see your Print String message print on what I assume is every time the sphere actor blueprint is ticked.

This will happen when you attach an actor that has overlap events to a character or if you create a child on the character blueprint and specify an actor with overlap events. Every time the character moves it continues to fire the event until you stop moving.

Workaround

I’ve setup my character with a capsule component which generates overlap events for all dynamic. When that components onBeginOverlap event fires I then attempt to cast the actor (in this case the SphereActor) into the SphereActor blue print just to make sure it’s the correct actor. If the actor is of the correct type I then send an interface event/message to that actor to begin processing damage and such.

Final Thoughts

I’m not really sure if this is actually a bug or that I just don’t fully understand how the engine works. If anyone has any ideas why this happens, please let me know. Also please let me know if you would like further clarification.

Using binary build version 4.1.0-2053896

Thanks,
Brent

Seems related to a problem I was having.

Yep I did try that, in fact I just created a brand new setup in the past five minutes just to test it again. It is just as I thought, the character is triggering the overlap.

This does seem to be very similar to the issue I’m having. My issue only seems to happen when I attach a blue print to a character or set that blueprint as a child and that blueprint uses an overlap event. I don’t have any problems when i add the blueprint to the level and run through it. The overlap event fires as it normally would.

Have you tried to post the Other Actor object from the the OnComponentDidBeginOverLap Event to the log/console? This would tell you what is triggering it.

Hello,
Thank you for your report. We were not able to investigate this on the engine version you reported, but there have been many version changes to UE4 since this question was first posted. With a new version of the Engine comes new fixes and it is possible that this issue has changed or may no longer occur. Due to timetable of when this issue was first posted, we are marking this post as resolved for tracking purposes.
If you are still experiencing the issue you reported in the current engine version, then please respond to this message with additional information and we will investigate as soon as possible. If you are experiencing a similar, but different issue at this time, please submit a new report for it.
Thank you.