I’m getting these errors when trying to compile code from this tutorial Quick Start Guide to Player Input in Unreal Engine CPP | Unreal Engine 5.2 Documentation
I am assuming the tutorial is outdated, as I’m using version 4.17. I just started using Unreal recently and don’t know how to solve these errors. In Visual Studio, this line is highlighted UCameraComponent* OurCamera = CreateDefaultSubobject(TEXT(“OurCamera”));
Here is the error log:
Compiling game modules for hot reload
Performing 3 actions (4 in parallel)
MyPawn.cpp
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(16) : error C2065: 'UCameraComponent': undeclared identifier
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(16) : error C2065: 'OurCamera': undeclared identifier
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(16) : error C2672: 'UObject::CreateDefaultSubobject': no matching overloaded function found
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(16) : error C2974: 'UObject::CreateDefaultSubobject': invalid template argument for 'TReturnType', type expected
C:\Program Files\Epic Games\UE_4.17\Engine\Source\Runtime\CoreUObject\Public\UObject/Object.h(95) : note: see declaration of 'UObject::CreateDefaultSubobject'
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(19) : error C2065: 'OurCamera': undeclared identifier
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(19) : error C2227: left of '->SetupAttachment' must point to class/struct/union/generic type
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(19) : note: type is 'unknown-type'
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(20) : error C2065: 'OurCamera': undeclared identifier
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(20) : error C2227: left of '->SetRelativeLocation' must point to class/struct/union/generic type
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(20) : note: type is 'unknown-type'
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(21) : error C2065: 'OurCamera': undeclared identifier
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(21) : error C2227: left of '->SetRelativeRotation' must point to class/struct/union/generic type
C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp(21) : note: type is 'unknown-type'
ERROR: UBT ERROR: Failed to produce item: C:\Users\Douglas\Documents\Unreal Projects\HowTo_PlayerInput\Binaries\Win64\UE4Editor-HowTo_PlayerInput-7677.dll
Total build time: 22.74 seconds (Local executor: 0.00 seconds)