C++ First Person Shooter Tutorial - 2.7 - Can't compile (UE 4.16.3)

I am following along this tutorial right here:
https://docs.unrealengine.com/latest/INT/Programming/Tutorials/FirstPersonShooter/2/7/index.html

For some reason, I can’t compile the FPSCharacter class the compiled Blueprint I have in the Blueprints folder is based upon. I tried setting the code back to what it was in 2.6, and it compiled just fine, meaning that there’s something that has to do with the code in this page. Can you please help me out? What is it I’m missing or not configured properly?

I am using UE4 4.16.3-3561208+++UE4+Release-4.16 and Microsoft Visual Studio Community 2017 Version 15.2 (26430.16), along with Visual C++ 2017 00369-60000-00001-AA608.

This is the code I have for FPSController.h:


// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "FPSCharacter.generated.h"

UCLASS()
class FPSPROJECT_API AFPSCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AFPSCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

	// Handles input for moving forward and backward.
	UFUNCTION()
	void MoveForward(float Value);

	// Handles input for moving right and left.
	UFUNCTION()
	void MoveRight(float Value);
	
	// Sets jump flag when key is pressed.
	UFUNCTION()
	void StartJump();

	// Clears jump flag when key is released.
	UFUNCTION()
	void StopJump();

	// FPS camera.
	UPROPERTY(VisibleAnywhere)
	UCameraComponent* FPSCameraComponent;
};

For FPSCharacter.cpp:


// Fill out your copyright notice in the Description page of Project Settings.

#include "FPSCharacter.h"
#include "Engine.h"
#include "FPSProject.h"

#include <iostream>

using namespace std;

// Sets default values
AFPSCharacter::AFPSCharacter()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	// Create a first person camera component.
	FPSCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
	// Attach the camera component to our capsule component.
	FPSCameraComponent->SetupAttachment(GetCapsuleComponent());
	
	// Position the camera slightly above the eyes.
	FPSCameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f + BaseEyeHeight));
	// Allow the pawn to control camera rotation.
	FPSCameraComponent->bUsePawnControlRotation = true;
}

// Called when the game starts or when spawned
void AFPSCharacter::BeginPlay()
{
	Super::BeginPlay();
	
	if (GEngine)
	{
		// Put up a debug message for five seconds. The -1 "Key" value (first argument) indicates that we will never need to update or refresh this message.
		GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("We are using FPSCharacter."));
	}

}

// Called every frame
void AFPSCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void AFPSCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	// Set up "movement" bindings.
	PlayerInputComponent->BindAxis("MoveForward", this, &AFPSCharacter::MoveForward);
	PlayerInputComponent->BindAxis("MoveRight", this, &AFPSCharacter::MoveRight);

	// Set up "look" bindings.
	PlayerInputComponent->BindAxis("Turn", this, &AFPSCharacter::AddControllerYawInput);
	PlayerInputComponent->BindAxis("LookUp", this, &AFPSCharacter::AddControllerPitchInput);

	// Set up "action" bindings.
	PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &AFPSCharacter::StartJump);
	PlayerInputComponent->BindAction("Jump", IE_Released, this, &AFPSCharacter::StopJump);
}

void AFPSCharacter::MoveForward(float Value)
{
	// Find out which way is "forward" and record that the player wants to move that way.
	FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::X);
	AddMovementInput(Direction, Value);
}

void AFPSCharacter::MoveRight(float Value)
{
	// Find out which way is "right" and record that the player wants to move that way.
	FVector Direction = FRotationMatrix(Controller->GetControlRotation()).GetScaledAxis(EAxis::Y);
	AddMovementInput(Direction, Value);
}

void AFPSCharacter::StartJump()
{
	bPressedJump = true;
	cout << bPressedJump << endl;
}

void AFPSCharacter::StopJump()
{
	bPressedJump = false;
	cout << bPressedJump << endl;
}

I have Engine.h as part of my preprocessor includes, because I remember working through an earlier page for the same tutorial project, and what I got was a compiler error saying “GEngine” is undeclared. It took me a little while to find out why it’s happening, but eventually I figured it out. It seems that the pages for the tutorial project are a bit out of date for the version of UE4 I have.

Output when I build the FPSProject solution:


1>------ Build started: Project: FPSProject, Configuration: Development_Editor x64 ------
1>Compiling game modules for hot reload
1>Parsing headers for FPSProjectEditor
1>  Running UnrealHeaderTool "C:\Users\gregp\Documents\Unreal Projects\FPSProject\FPSProject.uproject" "C:\Users\gregp\Documents\Unreal Projects\FPSProject\Intermediate\Build\Win64\FPSProjectEditor\Development\FPSProjectEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>Reflection code generated for FPSProjectEditor in 3.4524537 seconds
1>Performing 4 actions (4 in parallel)
1>FPSCharacter.cpp
1>FPSProject.generated.cpp
1>c:\users\gregp\documents\unreal projects\fpsproject\source\fpsproject\FPSCharacter.h(47): error C2143: syntax error: missing ';' before '*'
1>c:\users\gregp\documents\unreal projects\fpsproject\source\fpsproject\FPSCharacter.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\gregp\documents\unreal projects\fpsproject\source\fpsproject\FPSCharacter.h(47): error C2238: unexpected token(s) preceding ';'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.h(47): error C2143: syntax error: missing ';' before '*'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.h(47): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.h(47): error C2238: unexpected token(s) preceding ';'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Intermediate\Build\Win64\UE4Editor\Inc\FPSProject\FPSProject.generated.cpp(143): error C2039: 'FPSCameraComponent': is not a member of 'AFPSCharacter'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.h(10): note: see declaration of 'AFPSCharacter'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Intermediate\Build\Win64\UE4Editor\Inc\FPSProject\FPSProject.generated.cpp(143): error C2664: 'UObjectProperty::UObjectProperty(const UObjectProperty &)': cannot convert argument 1 from 'FObjectInitializer' to 'ECppProperty'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Intermediate\Build\Win64\UE4Editor\Inc\FPSProject\FPSProject.generated.cpp(143): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(18): error C2065: 'FPSCameraComponent': undeclared identifier
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(20): error C2065: 'FPSCameraComponent': undeclared identifier
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(20): error C2227: left of '->SetupAttachment' must point to class/struct/union/generic type
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(20): note: type is 'unknown-type'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(23): error C2065: 'FPSCameraComponent': undeclared identifier
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(23): error C2227: left of '->SetRelativeLocation' must point to class/struct/union/generic type
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(23): note: type is 'unknown-type'
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(25): error C2065: 'FPSCameraComponent': undeclared identifier
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(25): error C2227: left of '->bUsePawnControlRotation' must point to class/struct/union/generic type
1>C:\Users\gregp\Documents\Unreal Projects\FPSProject\Source\FPSProject\FPSCharacter.cpp(25): note: type is 'unknown-type'
1>ERROR : UBT error : Failed to produce item: C:\Users\gregp\Documents\Unreal Projects\FPSProject\Binaries\Win64\UE4Editor-FPSProject-16.dll
1>Total build time: 24.93 seconds (Local executor: 0.00 seconds)
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command ""C:\Program Files\Epic Games\UE_4.16\Engine\Build\BatchFiles\Build.bat" FPSProjectEditor Win64 Development "C:\Users\gregp\Documents\Unreal Projects\FPSProject\FPSProject.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.
1>Done building project "FPSProject.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please let me know!

So as an exercise in troubleshooting, I looked through your code and the tutorial.

// FPS camera.
UPROPERTY(VisibleAnywhere)
UCameraComponent* FPSCameraComponent;

Is incorrect as of 4.16/4.17 and should have the type of “class” before it.
as in

// FPS camera.
UPROPERTY(VisibleAnywhere)
class UCameraComponent* FPSCameraComponent;

Give that a try, and see if it works out for you.

I still think the tutorial should be slightly updated for the newer versions of UE4. Where can I find the release notes or update notes for this kind of tutorial?