Problems with Tutorials

I’m going through the tutorials, and am running into many compiler errors. For example, in Components and Collision, I had to add


#include "Components/SphereComponent.h"

so that the following would compile


USphereComponent* SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));

Then, on the next step, I get a compiler error I can’t figure out:


UStaticMeshComponent* SphereVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisualRepresentation"));
SphereVisual->SetupAttachment(RootComponent);


where “Pointer to incomplete class type is not allowed”. This error appears in many of the tutorials. I’m using 4.19.1. How do I fix this?

(P.S. I get a JSON error if I put “C++” in the topic title when previewing or posting this topic.)

Is StaticMeshComponent.h included somewhere?

If not, its saying “I don’t know enough about UStaticMeshComponent to do anything with it”.

Check out the IWYU Reference Guide.

If you’re don’t mind the investment, get your something like Visual Assist for Visual Studio.
Then you can just right-click stuff and get it to add in missing headers etc.

Thanks! I’ll look into it.

“Pointer to incomplete class type is not allowed” pretty much always means you need to #include “MissingClass.h” at the top your .cpp file.