Following tutorial, need help

Hi there,

I am currently working through this tutorial https://wiki.unrealengine.com/First_Person_Shooter_C%2B%2B_Tutorial and I have made it to the section called “Projectiles Interacting with the World”.
The problem I am having is that when i type the line:

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

I get an error that says

No instance of function template "FComponentHitSignature::__Internal_AddDynamic" matches the argument list
argument types are: (AFPSProjectile*, void (AFPSProjectile::*)(AActor *OtherActor, UPrimitiveComponent *OtherComp, FVector NormalImpulse, cosnt FHitResult &Hit), FName)
Object type is: FComponentHitSignature

FPSProjectile.h

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "FPSProjectile.generated.h"
UCLASS()
class FPSPROJECT_API AFPSProjectile : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AFPSProjectile();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Sphere collision component
	UPROPERTY(VisibleDefaultsOnly, Category = Projectile)
		USphereComponent* CollisionComp;

	// Projectile movement component
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Movement)
		UProjectileMovementComponent* ProjectileMovement;
	AFPSProjectile(const FObjectInitializer& ObjectInitializer);

	// Inits velocity of the projectile in the shoot direction
	void InitVelocity(const FVector& ShootDirection);

	// called when projectile hits something
	UFUNCTION()
		void OnHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
	
};

FPSProjectile.cpp

// Fill out your copyright notice in the Description page of Project Settings.
#include "FPSProject.h"
#include "FPSProjectile.h"
#include "UObject.h"
// Sets default values
AFPSProjectile::AFPSProjectile()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AFPSProjectile::BeginPlay()
{
	Super::BeginPlay();
	
}
// Called every frame
void AFPSProjectile::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
}
AFPSProjectile::AFPSProjectile(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	// Use a sphere as a simple collision representation
	CollisionComp = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereComp"));
	CollisionComp->BodyInstance.SetCollisionProfileName("Projectile");
	CollisionComp->OnComponentHit.AddDynamic(this, &AFPSProjectile::OnHit);
	CollisionComp->InitSphereRadius(15.0f);
	RootComponent = CollisionComp;
	// Use a ProjectileMovementComponenet to govern this projectile's movement
	ProjectileMovement = ObjectInitializer.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("ProjectileComp"));
	ProjectileMovement->UpdatedComponent = CollisionComp;
	ProjectileMovement->InitialSpeed = 3000.f;
	ProjectileMovement->MaxSpeed = 3000.f;
	ProjectileMovement->bRotationFollowsVelocity = true;
	ProjectileMovement->bShouldBounce = true;
	ProjectileMovement->Bounciness = .3f;
}
void AFPSProjectile::InitVelocity(const FVector& ShootDirection)
{
	if (ProjectileMovement)
	{
		// Set the projectile's velocity to the desired direction
		ProjectileMovement->Velocity = ShootDirection * ProjectileMovement->InitialSpeed;
	}
}
void AFPSProjectile::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
	if (OtherActor && (OtherActor != this) && OtherComp)
	{
		OtherComp->AddImpulseAtLocation(ProjectileMovement->Velocity * 100.0f, Hit.ImpactPoint);
	}
}

I’ve spent a ton of time researching and I’m not sure what to do, I can’t figure out why I seem to be the only one having this problem. I’ve read about the event not firing, but I am unable to even get it to compile. It’s probably a small typo but I’ve retyped it and still it doesn’t work.
Thank you.

Nevermind, I finally figured out why my signature was wrong. I found the primtivecomponent.h file and looked at the signature.

Yes I can share it. I’m at work right now though so I won’t be able to post it until later today. In the meantime, this video helped me a lot. When he goes into the primitvecomponent.h file and finds the signature of OnComponentOverlap, right next to it is OnComponentHit, which you can find yourself if you go into the file and just search for it. The tutorial code is missing an argument that is needed (only because the tutorial is so old). I’ll post the code tonight but I’d recommend looking into finding the solution that way because I now understand where the signatures come from.

can you share the solution?

what did you change “CollisionComp->OnComponentHit.AddDynamic(this, &AFPSProjectile::OnHit);” into?

The new signature is “::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)”

so you have to add UPrimitiveComponent* HitComp as the first parameter

Testing something