Unreal FPS C++ Tutorial

This tutorial has a few spots in the instructions that need correcting. which I managed to find my way around but others might not have such luck.

In some of the code through this next section - What the instructions tell you to add and the Example of code showing what the File such as FPSProjectile.cpp etc should now look like - DO NOT MATCH.

And I even tried to copy paste the Example code into my files as I thought I might be just one little thing not quite right, But same issue.
will not build successfully.

I have noticed other incorrectly typed instructions in this Tutorial also.

So anyways, I am now having trouble where visual studio will not Build successfully after applying the last parts of code in this section to get the BP_FPSProjectile to react / collide with the world and actors etc.

I am getting this Error in my Visual studio OUTPUT box etc Build section -

ERROR : UBT error : Failed to produce item: C:\Users\Darryl\Documents\Unreal Projects\FPSProject\Binaries\Win64\UE4Editor-FPSProject-3849.dll

It builds ok before adding a new Collision channel etc.
It’s the last part of this that seems to brake the project Build.

I have re tried the steps like 10 times and same result. but sometime a different .dll file in the Error code.

Any hints or idea what could be causing this ?

there are some problems with this Tutorial that need clearing up and fixing the instructions etc.

Cheers.

Update

This is the piece of Code that seems to be causing issues when added where it says to add it. -

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

adding this code in FPSProjectile.cpp Constructor as It shows in the Tutorial is causing issues with Build completing.
I get a can not produce win64 Binaries .dll files - example- 9431.dll file etc…

With out this code… the projectile is colliding & interacting with the (StaticMesh ) (Floor2) but will not DIE, keeps adding actors… the projectile do not go away / Die.

so this piece of the Code is not working for some reason…
Any help would be great.

Cheers
:slight_smile:

Sounds like you’re having the exact same issue as discussed in this thread and so the same solution should apply.

In your .h file change


UFUNCTION()
void OnHit(AActor * Actor, UPrimitiveComponent * PrimitiveComponent, FVector Vector, const FHitResult & HitResult);

to


UFUNCTION()
void OnHit(UPrimitiveComponent * PrimitiveComponent1, AActor * Actor, UPrimitiveComponent * PrimitiveComponent2, FVector Vector, const FHitResult & HitResult);

And in your .cpp file change


void AFPSProjectile::OnHit(AActor * Actor, UPrimitiveComponent * PrimitiveComponent, FVector Vector, const FHitResult & HitResult)
{
    if (Actor!= this && PrimitiveComponent->IsSimulatingPhysics())
    {
        PrimitiveComponent->AddImpulseAtLocation(ProjectileMovementComponent->Velocity * 100.0f, HitResult.ImpactPoint);
    }
}

to


void AFPSProjectile::OnHit(UPrimitiveComponent * PrimitiveComponent1, AActor * Actor, UPrimitiveComponent * PrimitiveComponent2, FVector Vector, const FHitResult & HitResult)
{
    if (Actor != this && PrimitiveComponent2->IsSimulatingPhysics())
    {
        PrimitiveComponent2->AddImpulseAtLocation(ProjectileMovementComponent->Velocity * 100.0f, HitResult.ImpactPoint);
    }
}

ok so I did that and visual studio now completes the build, But the projectiles are still not Dying after the 3 seconds…
any idea.?

I got the projectiles to die using the Blueprint editor etc. for now as the code is not working…

Also now the next step with Cross hairs, something is not working here… the build is completing But the Crosshairs are not showing on PIE mode. I have the Cross hair set in my HUD Blueprint mesh etc.
I have BP_FPSHUD Set as Default HUD in Project settings, but they are not showing up in play mode.

I think this Tutorial needs going over and Updating by the looks of things, too many issues…

Any help would be appreciated… Thanks.

Updated to post…

I have noticed a few things will not take affect in the PIE until you have saved and closed the UE4 Editor etc then Re open UE4 for the changes to take place.

The Cross hairs are now showing up in PIE mode…

Bit strange that I have to close and re open for some things to work…
but on to the next issue I guess lol…

Since it seems like you’re using the Hot Reload feature did you already try to restart the editor? You could also try to manually build your solution in Visual Studio but make sure the editor is NOT running anymore (check Task Manager etc.) or else it will still try Hot Reload.

ok thanks for the tip :slight_smile: