My class is based on AActor doesn’t it mean that InputComponent is included somewhere in it hierarchy? I am going through Rama Survival tutorial and his source codes:
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(48): error C2027: use of undefined type 'UCharacterMovementComponent'
1>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Engine\Classes\GameFramework/Character.h(24): note: see declaration of 'UCharacterMovementComponent'
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(48): error C2227: left of '->IsMovingOnGround' must point to class/struct/union/generic type
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(48): error C2227: left of '->IsFalling' must point to class/struct/union/generic type
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(48): error C2789: 'bLimitRotation': an object of const-qualified type must be initialized
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(48): note: see declaration of 'bLimitRotation'
1>D:\Dokumenty\Projects\Unreal Engine\RYFT\Source\RYFT\PlayerCharacter.cpp(52): error C2065: 'Val': undeclared identifier
1>ERROR : UBT error : Failed to produce item: D:\Dokumenty\Projects\Unreal Engine\RYFT\Binaries\Win64\UE4Editor-RYFT.pdb
Yep it worked however PlayerInputController calls are still highlighted with message: “Pointer to incomplete class is not allowed on UInputComponent pointer”. Whats more, why removing “class” keyword fix it? According to this stackoverflow topic it should be valid in that case because we only indicating that that UInputController is a class.
class declares this as a new class what we want in case of a header file because we cant include the “original” there because otherwise it would casue circular dependency but in the cpp we dont want that because in an empty class (incomplete class) there is nothing we could reference to (and thats what throws the error); in the cpp file we want an reference to the actual class and in the cpp we can include it without causing circular dependency. I think this explains it as well.
I know I’m not the OP, but I’m getting the same problem. I get that we need to include the original class, but what directory is the original class in? Following a video tutorial, it appears that the error isn’t thrown there, yet it is thrown here.
I noticed that everything included in my cpp and h files match his, albeit with more inclusions than what he has, and it still throws the same error.
It only makes me angrier when I notice how the line above it (Super::SetupPlayerInputComponent(PlayerInputComponent() throws no errors yet the line below it (PlayerInputComponent->BindAxis(“MoveForward”, this, &AMyCharacter::MoveForward) does throw an error.
Following up from my comment on EagleOwl’s answer, I found out exactly what needs to be done and why.
Add #include “Components/InputComponent.h” to the top of your file. Apparently UE4 encourages you to import only what you need by default, and then manually import everything else afterwards.