4.3 Add Dynamic On Component Overlap error
The new 4.3 update has been causing some issues with my code. I have an actor which consists of a UBoxComponent that should call another function on component overlap. It was working fine in Version 4.2 when I used AddDynamic to delegate from OnComponentOverlap to the function I wanted it to call, but when I converted the project to Version 4.3 I got compiler error C2664:
'void TMulticastScriptDelegate::Add(const TScriptDelegate &)' : cannot convert argument 1 from 'void (__cdecl ALevelChangeDetection:: )(AActor ,UPrimitiveComponent *,int32)' to 'const TScriptDelegate &'
Does anyone have an idea what might be causing this, or a better way to call a function on component overlap? I didn't see anything in the release notes that looked relevant. I also tried pasting the code into a new 4.3 project in case the conversion process was the problem, but I still got the same error.
Here is the header file:
and the source file:
asked Jul 18 '14 at 03:25 AM in C++ Programming
It seems that the new 4.3 update brought new signatures for the overlap functionality.
I've fixed this by using the delegate for the begin overlap signature (that's outlined in PrimitiveComponent.h by the DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams macro, here) and should give you an Overlap function declaration that looks like:
If you're ever going to use the end overlap, it uses a different signature, so use this function declaration instead:
This should fix your compiler errors :)
EDIT: Also (for other people reading this), if your overlap does not work, make sure to add [YourGameName]_API to your class declaration, like so:
Follow this question
Once you sign in you will be able to subscribe for any updates here