x

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"

How do you correct compile errors from 4.9 tutorials?

I'm getting these errors when trying to compile code from this tutorial https://docs.unrealengine.com/latest/INT/Programming/Tutorials/PlayerInput/index.html

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)

Product Version: UE 4.17
Tags:
more ▼

asked Oct 19 '17 at 06:30 PM in C++ Programming

avatar image

xDigDoug
1 1 4

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

The solution I found (Courtesy of GameDev Discord https://discordapp.com/invite/vupRVHT ) was to find and include the appropriate header file, in this case

Runtime/Engine/Classes/Camera/CameraComponent.h

Located here

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Camera/UCameraComponent/index.html

more ▼

answered Oct 19 '17 at 08:17 PM

avatar image

xDigDoug
1 1 4

(comments are locked)
10|2000 characters needed characters left

Replace your initialization of camera with this line

 UCameraComponent* OurCamera = ObjectInitializer.CreateDefaultSubobject(this, TEXT("OurCamera"));

more ▼

answered Oct 19 '17 at 07:45 PM

avatar image

ColdSteel48
457 6 13 19

(comments are locked)
10|2000 characters needed characters left
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