Overlap events fired twice

Hi, I am a bit stuck with this. Well it is more annoying than blocking. Every time the character steps on the pressure pad, the “Activated” message is fired twice.
Same when he steps away, the deactivated message is fired twice.First I was trying to register the event in the constructor but I had to put it in beginPlay because it wasn’t working. I kinda feel like it’s something happening in the Editor as I have double checked my code compared to yours but I don’t know what’s amiss. If anyone has a clue what’s going on, please feel free to share.
Thanks guys

B

1 Like

If you don’t register in the C++, does that remove both events? Have you fully restarted the editor since moving away from the constructor. This stuff can easily get cached.

Yes I have commented out the line that registers the OnComponentBeginOverlap event and it removes both events. And yes I have restarted Editor today and I have no overlap begin event and two overlap end events, which were not commented out. I then uncommented the line and now I have the two messages back. So I don’t think the cache is the culprit. I was thinking somehow twi parts of the trigger emitted an overlap event at once or the player generates the event twice…

I added other actor and component to the UE_LOG and the same actor and the trigger volume gernerate the collision each time.

So still an issue?

The below is tested on: Unreal engine Version: 4.18.1-3754814+++UE4+Release-4.18
IF you are certain your code is correct you could try the stupid “solution” below:

I had the same issue, with sometimes events even firing 4 times.
Strangely enough the deactivate event that was exactly the same as the activate event only fired once as it should.

Perhaps even more strangely after several project resets (closing and then reopening the project) it eventually just started working properly (this took multiple restarts because at first this didn’t do anything).

The code remained untouched and I didn’t change a thing.
So you might get it working by just restarting your project a few times, perhaps when you close it you remove the BP’s in the level first and reopen your project and place them back?

It’s likely something cached in the editor. Restarts and total recompiles always help in such cases.

If you have X players the Log will be fired X times, but the event is fired only once, I think the logs are separated for each player. Props to someone in the Q&A who posted that.

1 Like

For wut i did is:

  • use AddUniqueDynamic instead
  • put these into the “beginplay”

I wasn’t able to get the AddUniqueDynamic working. But, if I put a HasAuthority() check in the overlap event It only prints once now.

Going through the multiplayer course and searching from Google came across this post on this same lesson. Brought the number of players down to 1 and it worked as expected. Thanks for posting this - I hadn’t looked in the Q&A yet. Thanks - you saved me a bunch of time. Now I need to experiment to figure out how to include the client name / info in the log to make the log source more clear. :slight_smile:

I have the same issue and I’ve encountered it before in other contexts. I’m on UE4 4.25.3. This issue relates to connecting the platforms to the triggers on the Unreal Multiplayer Master course, section 1.16. In this case, when I walk into the platform trigger two overlap events are fired causing the implementation used in the lesson to not work as the active trigger count always increments by 2, but decrements by 1. Here are a few odd things I’m finding:
-Putting the initialization (TriggerVolume->OnComponentEndOverlap.AddDynamic) in BeginPlay causes the game to take quite a while longer to load when playing in editor.
-I logged some variables to see if the issue was being caused by both the collision cylinder and the mesh overlapping, but that does not APPEAR to be the case:
LogTemp: : Activated
LogTemp: : Plus - Active Triggers: 1
LogTemp: : Overlapped Other Actor: ThirdPersonCharacter_2
LogTemp: : Overlapped Other Component: CollisionCylinder
LogTemp: : Activated
LogTemp: : Plus - Active Triggers: 2
LogTemp: : Overlapped Other Actor: ThirdPersonCharacter_2
LogTemp: : Overlapped Other Component: CollisionCylinder
-I tried doing a HasAuthority check and I’m playing with 1 player, but it still generates two overlap events.
-AddUniqueDynamic did “fix” the issue, but it still bugs me and I’d like to know what’s going on. I’m also really bothered by the fact that OnComponentBeginOverlap has no meaningful documentation, other than the odd little coding tutorial blurb which is surprisingly hard to get to pop up on Google.

Also, putting
TriggerVolume->OnComponentBeginOverlap.AddDynamic(this, &APlatformTrigger::OnOverlapBegin);
TriggerVolume->OnComponentEndOverlap.AddDynamic(this, &APlatformTrigger::OnOverlapEnd);
in the constructor instead fixes the double overlaps, but then EndOverlap doesn’t work.

Is it possible you are registering for the overlap on both the client and server? I had a similar issue and realized I needed to use a HasAuthority() check to prevent the server from catching the overlapped event.

I had the same problem in UE 5.03 and the HasAuthority() check solves the problem and I think it has sense.
We want the server to control the overlap, not the client.
Thanks!!

Where do you place the HasAuthority()? I use UE 5.03, too, but I still get two Overlap events. It doesn’t matter if I place the check on “TriggerVolume->OnComponentBeginOverlap.AddDynamic(this, &APlatformTrigger2::OnOverlapBegin);” (at BeginPlay()) or on the “UE_LOG(LogTemp, Warning, TEXT(“Activated”));” it always fires twice.

The check should be in the event itself. Have a look at the lecture code in github. This will give you some idea of where to place the checks.

The check is placed in the event right before calling the UE_LOG.

The code in github doesn’t use the check and I have to use AddDynamic in BeginPlay because calling it in the constructor doesn’t work at all for me, which is different from the code in github, too.

*EDIT: It’s the ThirdPersonCharacter causing the problem.

Adding in BeginPlay is fine. I think this is related to a change in UE, and I think was necessary from 4.25 onwards if I recall.

Privacy & Terms