First Person Shooter Tutorial 3.4 Compile Error

So, I’m doing the First Person Shooter Tutorial in the learn section. In step 3.4: Getting Projectiles to Interact with the World, there is a line that won’t compile for me:

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

The message log tells me this:

Compiling game modules for hot reload
Performing 2 actions (3 in parallel)
error C2664: 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UPrimitiveComponent *,AActor *,UPrimitiveComponent *,FVector,const FHitResult &>::__Internal_AddDynamic<AFPSProjectile>(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 &)'
note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
ERROR: UBT ERROR: Failed to produce item: FPSProject\Binaries\Win64\UE4Editor-FPSProject-3409.dll
Total build time: 3,84 seconds

Hey Cedrei,

It looks like the function signature for OnHit is incorrect.

Try this instead:

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

Had the same Problem, Kyle’s answer solved it for me.