x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[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\Noah\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\Noah\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\Noah\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\Noah\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); 



Product Version: UE 4.12
Tags:
more ▼

asked Jun 21 '16 at 08:45 PM in C++ Programming

avatar image

TechnoScientist
30 2 6 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first
  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 ;P

more ▼

answered Jun 21 '16 at 09:49 PM

avatar image

Nachtmahr
7k 143 28 172

avatar image TechnoScientist Jun 22 '16 at 02:08 AM

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

avatar image drew767 Dec 18 '16 at 10:57 AM

THANK YOU!!!

avatar image Murphy Diana Dec 20 '18 at 02:16 PM

Thank you!!! ❤️❤️

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You guys are the best. Thansk

more ▼

answered Jul 11 '18 at 01:37 AM

avatar image

Bruce Leroy
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question