Registering Actor Colliding with landscape
Hello, I've been working on creating NPC Ai that randomly moves around the environment but avoids obstacles. I've set up object avoidance to use an interaction sphere around the actor, when the sphere overlaps with another static mesh it triggers an "OnComponentBeginOverlap" event. This works great for most things, but Landscapes don't have the option to generate component overlap events. My solution was to get my actor to generate an "OnComponentHit" event to register when the actor's interaction sphere collides with a landscape.
My code for my overlap events work:
However when I try to write an OnComponentHit event using the same logic, it fails to compile. I've tried two different methods shown below:
I always end up with the same error:
Error C:\Users\NCY\Documents\UnrealProject\Source\Private\NPC.cpp(39) : error C2664: 'void TBaseDynamicMulticastDelegate::__Internal_AddDynamic(UserClass ,void (__cdecl ANPC:: )(AActor ,UPrimitiveComponent ,FVector,const FHitResult &),const TCHAR )': cannot convert argument 2 from 'void (__cdecl ANPC:: )(AActor ,UPrimitiveComponent ,int32,bool,const FHitResult &)' to 'void (__cdecl ANPC:: )(AActor ,UPrimitiveComponent *,FVector,const FHitResult &)' Info with Info [ Info UserClass=ANPC Info ] Error C:\Users\NCY\Documents\UnrealProject\Source\Private\NPC.cpp(39) : note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
What am I doing wrong?
asked May 05 '16 at 01:40 PM in C++ Programming
Your OnHit does not have the same Signature as OnOverlap!
for versions bellow 4.12 use
for 4.12 and above
answered Jun 02 '16 at 12:04 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here