[C++] OnComponentBeginOverlap Error with .AddDynamic

I am using UE 4.12 and trying to set up Overlapping events in C++ but I can not compile my code I have narrowed it down to these two lines… It has to do with .AddDynamic I believe.

Item.cpp

TriggerComponent->OnComponentBeginOverlap.AddDynamic(this, &AItem::TriggerEnter);

TriggerComponent->OnComponentEndOverlap.AddDynamic(this, &AItem::TriggerExit);

I have been trying to solve this problem for many hours but I cannot find a solution. I have looked online and on the UE4 documentation to find that my formatting is correct. So Idk what the problem is… maybe it is a new issue in 4.12. Does anyone know how to fix this issue?

Here is my compiler error:

C:\Users\\Documents\Unreal Projects\DrunkSimulator\Source\DrunkSimulator\Item.cpp(17): error C2664: 'void TBaseDynamicMulticastDelegate::__Internal_AddDynamic(UserClass *,void (__cdecl AItem::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &),FName)': cannot convert argument 2 from 'void (__cdecl AItem::* )(AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)' to 'void (__cdecl AItem::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)'

2>          with

2>          [

2>              UserClass=AItem

2>          ]

2>  C:\Users\\Documents\Unreal Projects\DrunkSimulator\Source\DrunkSimulator\Item.cpp(17): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

2>C:\Users\\Documents\Unreal Projects\DrunkSimulator\Source\DrunkSimulator\Item.cpp(18): error C2664: 'void TBaseDynamicMulticastDelegate::__Internal_AddDynamic(UserClass *,void (__cdecl AItem::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32),FName)': cannot convert argument 2 from 'void (__cdecl AItem::* )(AActor *,UPrimitiveComponent *,int32)' to 'void (__cdecl AItem::* )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,int32)'

2>          with

2>          [

2>              UserClass=AItem

2>          ]

2>  C:\Users\\Documents\Unreal Projects\DrunkSimulator\Source\DrunkSimulator\Item.cpp(18): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

And this is my Declaration of TriggerEnter and TriggerExit in Item.h

Item.h

UFUNCTION()

	void TriggerEnter(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);


UFUNCTION()

	void TriggerExit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
2 Likes

UFUNCTION()
void TriggerEnter(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult);

 UFUNCTION()
     void TriggerExit(class UPrimitiveComponent* HitComp, class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex); 

Missing Parameter. new in 4.12 :stuck_out_tongue_winking_eye:

3 Likes

Thank you!! It worked beautifully. Your help was much appreciated!

THANK YOU!!!

You guys are the best. Thansk

Thank you!!! :heart::heart:

Was my problem in 5.1 and you solved it… thanks !! … :orange_heart: