C++ FPS Tutorial 3.4 Error

Hi everyone,

This question has been asked a lot already, but I do not understand the solutions given:

In the C++ FPS Tutorial 3.4 (Getting Projectiles to Interact with the World), the compiler generates an error. I know that it’s using an old version of the Unreal Engine, but what do I change the following lines of code to?

FPSProjectile.h

// Function that is called when the projectile hits something.
UFUNCTION()
void OnHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);

FPSProjectile.cpp

// Function that is called when the projectile hits something.
void AFPSProjectile::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
    if (OtherActor != this && OtherComponent->IsSimulatingPhysics())
    {
        OtherComponent->AddImpulseAtLocation(ProjectileMovementComponent->Velocity * 100.0f, Hit.ImpactPoint);
    }
}

FPSProjectile.cpp (under AFPSProjectile::AFPSProjectile()

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

Thank you for your help.

P.S. Would it be possible to update the tutorial to match the changes to the .AddDynamic function?

I found a solution:

FPSProjectile.h (old)

// Function that is called when the projectile hits something.
UFUNCTION()
void OnHit(class AActor* OtherActor, class UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);

FPSProjectile.h (update)

// Function that is called when the projectile hits something.
UFUNCTION()
void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit);

FPSProjectile.cpp (old)

// Function that is called when the projectile hits something.
void AFPSProjectile::OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
    if (OtherActor != this && OtherComponent->IsSimulatingPhysics())
    {
        OtherComponent->AddImpulseAtLocation(ProjectileMovementComponent->Velocity * 100.0f, Hit.ImpactPoint);
    }
}

FPSProjectile.cpp (update)

// Function that is called when the projectile hits something.
void AFPSProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComponent, FVector NormalImpulse, const FHitResult& Hit)
{
    if (OtherActor != this && OtherComponent->IsSimulatingPhysics())
    {
	    OtherComponent->AddImpulseAtLocation(ProjectileMovementComponent->Velocity * 100.0f, Hit.ImpactPoint);
    }
}

FPSProjectile.cpp (under AFPSProjectile::AFPSProjectile() (no changes needed)

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

I hope others who need the same solution will find this helpful.

Thanks a ton!