Only OverlapEnd event triggering

Hi All
Not much activity on these forums but hope that my post catches someone’s interest.

If my code has the two Add Dynamic calls to add callbacks for OnComponentBeginOverlap and OnComponentEndOverlap in the constructor, then only the End Overlap event seems to be registered.
When play testing the game only “Deactivated” shows when exiting the volume. If I register the events in BeginPlay then the demo behaves as expected.

This is an OK workaround, but I’m very pedantic as a programmer and wondering why registering the events in the constructor seems to register only the overlapEnd.

In the future, if I’m working on a 16 player game, for example, the BeginPlay will be called for each player, right? So this code is simple right now, but if there are a few dozen events registered from a few dozen different active objects in a non-trivial game then this could potentially cause some unintended problems.

I’m using Unreal 4.23.0 and visual studio 2019

Thanks in advance
Kind regards
Lloyd

Ok, so it turns out if I deleted the Blueprint class that derived from the C++ class, then recreated it from scratch, both of the events registered correctly. Very, very strange. I tried this after finding a post on the Unreal Engine forums suggesting it.

always bind events in begin play, to ensure all of the engine delegates have been
instantiated before trying to subscribe to it. Instantiation ordering is not guaranteed.

Privacy & Terms