1

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

timgfx
  • 199
  • 2
  • 14
  • This link should help you: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/50863-attach-staticmesh-to-actor – Asesh Dec 16 '17 at 17:05
  • @Asesh I just tried but I think im just doing something essential wrong. [.h](https://i.gyazo.com/479e3c18d2b13e2b941d0f5d9a93576c.png) [.cpp](https://i.gyazo.com/ed1b1e8d8db3637649a652e9e0a6ec8a.png) tons of red lines, idk what ive done wrong and i have no clue how to fix it. ive been trying this for like 5 hours now and no google result has helped :/ – timgfx Dec 16 '17 at 17:14
  • Then post those error messages too – Asesh Dec 16 '17 at 18:26
  • 1
    include "StaticMeshComponent.h" in your .cpp. – Rotem Dec 17 '17 at 12:29

1 Answers1

1

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.

Gustavo Otero
  • 91
  • 2
  • 11