Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

FPS Tutorial C++

I am currently doing the First Person Shooter Tutorial in the C++ Programming Tutorial section from the Unreal wiki page. I am working an a macbook pro running macOs 10.12.5 with the UE 4.16.1. I reached 2.7 - Changing the camera view, but I cannot compile the code from the tutorial. Is there a difference between 4.15 and 4.16 that i am not aware of? I will post the files and and the compile log and keep looking for other answers. Thanks in advance for the help.


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

 #include "FPSCharacter.h"

     // 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.
     // 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()
     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(class UInputComponent* 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;

 void AFPSCharacter::StopJump()
     bPressedJump = false;

FPSCharacter.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"

 class FPSTUTORIAL_API AFPSCharacter : public ACharacter
     // Sets default values for this character's properties
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
     // Handles input for moving forward and backward.
     void MoveForward(float Value);
     // Handles input for moving right and left.
     void MoveRight(float Value);
     // Sets jump flag when key is pressed.
     void StartJump();
     // Clears jump flag when key is released.
     void StopJump();
     // FPS camera.
     UCameraComponent* FPSCameraComponent;

Compile Log

Product Version: UE 4.16
uecompilelog.txt (32.1 kB)
more ▼

asked Jun 06 '17 at 06:17 PM in C++ Programming

avatar image

1 1 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You need to add this to your AFPSCharacter.h:

 #include "Camera/CameraComponent.h"
more ▼

answered Jun 06 '17 at 08:31 PM

avatar image

ImVawx ♦♦ STAFF
6.8k 114 18 128

avatar image juanpedroghm Jun 07 '17 at 12:43 PM

Thank you that was it. I dont know why the tutorial code is not complete but i should have guessed that it was a missing include.

avatar image sosssego Jul 05 '17 at 06:05 PM

I had the same error, and even after adding the

 #include "Camera/CameraComponent.h"

I still getting an error in the FpsCharacter.c in the line:


It says that UCapsuleComponent is uncompatible with USceneComponent.

I am using unreal engine 4.16.1, any ideas?

avatar image Vawx Jul 07 '17 at 03:12 AM

Change to:

avatar image sosssego Jul 07 '17 at 01:42 PM

just found out that: #include "Components/CapsuleComponent.h" added to the .cpp file solves the problems as well. Epic should be trying to get fast compile times changing the header files included...

avatar image SoulThief Jul 18 '17 at 05:35 AM

Thanks Kyle.

I was having same problem and #include "Camera/CameraComponent.h" worked for me :)


(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question