Ongoing C++ Gameplay Example Series: Making a Survival Game

I am able to compile the code with no problem, but when i try to edit the game mode…

Lets say all i did was added one line with 0 code and i get errors… please review images… image one is normal code from github complie works fine… image two is one line added with tons of errors…how does this happen? I tried reinstalling VS, generating project files again…

This is due to how UE4 merges cpp files before compile, adding empty line changes timestamp of gamemode, and sudenly there is include missing, just add #include “BehaviorTreeComponent.h” after #include “SMutator.h” and it will compile …

I am using 4.19… now looks like i have this error. …also added “#include “BehaviorTree/BehaviorTreeComponent.h”” in the SGameMode.h

Anybody :frowning:

Hello,
does anyone know how the shooting in the center is made?

I’m having exactly the same problem on 4.20 (downloaded and compiled yesterday), but I’m on Linux. The error is the same though. Any way to solve this without having to go back to 4.18? (the download and setup time is pretty big and I’d like to avoid it at all cost)

Thank you

UPDATE:
There was a “bug” in the last commit:

There shouldn’t be any problems, since the && has lower precedence than the ||, and everything should just compile, but it didn’t work for me and I have to explicitly set the () around the first group of &&.
is the code that compiles:


            if (
                (
                    !Actor->IsA(ALevelScriptActor::StaticClass())
                    && !Actor->IsA(ASMutator::StaticClass())
                    && Actor->GetRootComponent() != nullptr
                    && Actor->GetRootComponent()->Mobility != EComponentMobility::Static
                )
               ||
                (
                    !Actor->IsA(AStaticMeshActor::StaticClass())
                    && !Actor->IsA(ALight::StaticClass())
                )
               )

Notice that I only added extra () around the first 4 && conditions. Either add the () yourself, or copy/paste that code.

How did I debug it?

I manually compiled the client:

Then I checked the logs in the output, and <home>/Library/Logs/Unreal Engine/LocalBuildLogs/Log.txt

Thank you, sorry only just seen this as I’ve been away :slight_smile:

Thank you very much, I’ll be trying this project again soon!

Just a heads up for anyone else having issues on 4.20 and Linux:
Trying to package the example for release does not work from the Editor. I always get inotify errors.
I actually increased the inotify to a huge amount and the error persists: fs.inotify.max_user_watches = 2097152

So the only “fix” I found was to manually compile it like this: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums
My engine source is in an external sata hard drive over usb 3.0, so the problem may be related to that, or not.

I tried to recreate the project in engine version 4.21.2. In the Character.h he declares a USpringArmComponent and UCameraComponent yet he never includes the header files for these classes nor does a forward declaration. My project won’t compile without including the header files. Both versions are 4.21.2. Anyone know why this is happening? Where are the includes hiding?

Got it working in 4.22

First i needed to update my VS2017


 
 WindowsPlatformCompilerSetup.h(22): error C2338: Visual Studio 2017 versions 15.7 and 15.8 are known to have code generation bugs that affect UE4. Please update to version 15.9. 

Solution: Downloaded the Latest VS 2017
.microsoft.com/en-us/vis…s2017-relnotes

Secondly i received compile errors for the Possess() and UnPossess() calls in SZombieAIController.h


 
 error C3248: 'AController::Possess': function declared as 'final' cannot be overridden by 'AEnemyAI::Possess' error C3248: 'AController::UnPossess': function declared as 'final' cannot be overridden by 'AEnemyAI::UnPossess'  

Solution:
I fixed this by renaming them OnPosess() and OnUnPossess() in header and SZombieAIController.cpp which makes them a custom function instead of an Override function

Thirdly i received several compile errors concerning FCollisionQueryParams TraceParams in a few files




 error C2039: 'bTraceAsyncScene': is not a member of 'FCollisionQueryParams' 

I simply commented them out and this allowed me to build the solution.

Solution:


//TraceParams.bTraceAsyncScene = true;

**Disclaimer; **
Simply a workaround to build project not getting the engine Possess override function and missing a collision call several places. Toms an instructor figured i could help out so i can continue learning as well!

still doesn’t work for me… i did exactly what @STLWalterSobchyk said but still… im really need this to work, can anyone help, i tried to use UE 4.21.2 and UE 4.22.2. Any help is really appreciated!

It looks like upgraded the project on GitHub yesterday to work with 4.22.

Ok… i was able to load the project, but can anyone help me with the retargeting… Everytime i tried to retarget the animation using one of the paragon character, the gun from the original character just move to the place where it is not supposed to be… Plz really need this to work

I need to handle all of the death events my self but I can seem to find where some of the functions are getting called. UnFreeze(), and StartSpectating(), I know they are in the Player Controller, but I cant seem to find where they are getting called from, When running log statments after taking damage it calls onDeath(), Die(), but neither of the those call start spectating. Any help would be great.

i like this alot

So useful work, thank you!

Hello , I am curious about why in the hitscan code you the tracing twice. Once from the camera position and one then from the muzzle. Like this:



void ASWeaponInstant::FireWeapon()
{
     const FVector AimDir = GetAdjustedAim();
     const FVector CameraPos = GetCameraDamageStartLocation(AimDir);
     const FVector EndPos = CameraPos + (AimDir * WeaponRange);

    /* Check for impact by tracing from the camera position */
**    FHitResult Impact = WeaponTrace(CameraPos, EndPos);**

    const FVector MuzzleOrigin = GetMuzzleLocation();

    FVector AdjustedAimDir = AimDir;
    if (Impact.bBlockingHit)
    {
         /* Adjust the shoot direction to hit at the crosshair. */
         AdjustedAimDir = (Impact.ImpactPoint - MuzzleOrigin).GetSafeNormal();

         /* Re-trace with the new aim direction coming out of the weapon muzzle */
**         Impact = WeaponTrace(MuzzleOrigin, MuzzleOrigin + (AdjustedAimDir * WeaponRange));**
    }
    else
   {
         /* Use the maximum distance as the adjust direction */
         Impact.ImpactPoint = FVector_NetQuantize(EndPos);
   }

   ProcessInstantHit(Impact, MuzzleOrigin, AdjustedAimDir);
}


In general I have seen in different examples that as the origin of the ray different things are used: the camera position, in your Udemy course you use the actor eyes with GetActorEyesViewPoint() function and the muzzle as well. I know that obviously in the case of AI the camera position can’t be used, but what’s the rationale behind these different approaches?

@coyoneda It’s common to do multiple linetraces, one comes from the camera and does the actual damage, the other comes from the muzzle location of the gun and is used for cosmetic things like tracer , making it look like there is a bullet coming from the weapon. This helps with player standing next to a wall or behind cover, if the actual linetrace came from the gun chances are it would get blocked by something, but because it comes from the camera you only need line of sight.

2 Likes

Can’t wait and I hope there will be more videos,
Thanks