Following UE4 Tutorial - Pawn Class cant add USpringarmComponent

4.16 changed how you include classes. You can either follow the tutorial with the version of the engine it was used for, or adapt what was changed in 4.16.

Add the following to your pawn.h file:

#include "GameFramework/SpringArmComponent.h"
 #include "Camera/CameraComponent.h"

Also, here is a link to what has changed in 4.16: Include What You Use

1 Like

Hi I’m coming from a comfortable Unity background and I’m trying to move over to UE4, following this guide.
https://docs.unrealengine.com/latest/INT/Programming/Tutorials/PlayerCamera/1/index.html

I have made the Pawn class and I am currently editing the header files they should look like this as per the tutorial.

#include "GameFramework/Pawn.h"
#include "PawnWithCamera.generated.h"

UCLASS()
class HOWTO_PLAYERCAMERA_API APawnWithCamera : public APawn
{
    GENERATED_BODY()

public:
    // Sets default values for this pawn's properties
    APawnWithCamera();

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

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

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

protected:
    UPROPERTY(EditAnywhere)
    USpringArmComponent* OurCameraSpringArm;
    UCameraComponent* OurCamera;
};

However, when I go to add this VS states that these components are not defined am I missing a header include??

protected:
        UPROPERTY(EditAnywhere)
        USpringArmComponent* OurCameraSpringArm; // here
        UCameraComponent* OurCamera; //and here

This is my code

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

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "APawnWithCamera.generated.h"

UCLASS()
class CHARACTERMOVEMENT_API AAPawnWithCamera : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	AAPawnWithCamera();

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;

protected:
	UPROPERTY(EditAnywhere)
		UCameraComponent* OurCamera;
		USpringArmComponent* OurCameraSpringArm;
	
};

Thanks.