AddDynamic on FPSTutorial Sec.3.4 gives error

The line:

CollisionComponent->OnComponentHit.AddDynamic(this, &AFPSProjectile::OnHit);

Won’t compile. It gives the errors:

Severity Code Description Project File Line
Error C2664 ‘void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UPrimitiveComponent *,AActor *,UPrimitiveComponent *,FVector,const FHitResult &>::__Internal_AddDynamic(UserClass ,void (__cdecl AFPSProjectile:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent ,FVector,const FHitResult &),FName)’: cannot convert argument 2 from 'void (__cdecl AFPSProjectile:: )(AActor *,UPrimitiveComponent ,FVector,const FHitResult &)’ to 'void (__cdecl AFPSProjectile:: )(UPrimitiveComponent *,AActor *,UPrimitiveComponent *,FVector,const FHitResult &)’ FPSProject E:\Users\MikeSSD\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSProjectile.cpp 19

Severity Code Description Project File Line
Error (active) no instance of function template “FComponentHitSignature::__Internal_AddDynamic” matches the argument list FPSProject e:\Users\MikeSSD\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSProjectile.cpp 19

Severity Code Description Project File Line
Error MSB3075 The command ““C:\Epic Games\4.13\Engine\Build\BatchFiles\Build.bat” FPSProjectEditor Win64 Development “E:\Users\MikeSSD\Documents\Unreal Projects\FPSProject\FPSProject.uproject” -waitmutex” exited with code 5. Please verify that you have sufficient rights to run this command. FPSProject E:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 37

They’ve changed the input on the function. It is now (UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit), at least for 4.12. I haven’t made the transfer yet so I’m not sure.

I was just working on collisions. You have to build the function up perfectly, or else everything will crash. it’s wonderful.

As for your function, it looks good. The C++ 1st person shooter example helped me immensely with this.

Thanks! adding the UPrimitiveComponent* HitComp fixed it! :slight_smile:

For other people interested in this, you can find the signature in the file

Runtime/Engine/Classes/Components/PrimitiveComponent.h

It looks like this:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams( FComponentHitSignature, UPrimitiveComponent*, HitComponent, AActor*, OtherActor, UPrimitiveComponent*, OtherComp, FVector, NormalImpulse, const FHitResult&, Hit );