Reputation: 329
I am trying to spawn a floor, I have the static mesh made and the actor class made. I added this in the header:
UStaticMeshComponent* MyPtr;
I added this in the constructor:
MyPtr = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CubeMesh"));
ConstructorHelpers::FObjectFinder<UStaticMeshComponent>MeshRef(TEXT("Game/ThirdPerson/Meshes/CubeMesh.CubeMesh"));
MyPtr->SetStaticMesh(MeshRef);
The last MyPtr Im using says that its a pointer to an incomplete class. I really don't know what's going wrong and ive been trying for quite some time.
As far as I know MyPtr is a UStaticMeshComponent, which is a class so how can it give that error. Anyway, Im new to this language, I've googled and am still confused as to why this is happenning. Help is greatly appreciated
Upvotes: 1
Views: 9951
Reputation: 91
you just need to include "StaticMeshComponent.h " in your cpp or header file
#inclide "Runtime/Engine/Classes/Components/StaticMeshComponent.h "
check this https://forums.unrealengine.com/development-discussion/engine-source-github/102177-iwyu
Rather than including big headers like Engine.h and UnrealEd.h everywhere, each header now includes just what it needs. There will doubtless be a few teething problems switching over to this, but we've been seeing a 20-50% improvement on build times in its staging branch, so hopefully it'll be worthwhile.
Upvotes: 1