Cannot attach UArrowComponent to RootComponent

I’m trying to attach an arrow component to my Actor through code, but when compiling I get the following error:

error C2227: left of '->AttachParent' must point to class/struct/union/generic type

Here is the code that is causing the error:

.h

UPROPERTY(VisibleDefaultsOnly, Category = "Spawner")
class UStaticMeshComponent* SpawnerMesh;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Spawner")
class UArrowComponent* SpawnPoint;

.cpp

SpawnerMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SpawnerMesh"));
RootComponent = SpawnerMesh;

SpawnPoint = CreateDefaultSubobject<UArrowComponent>(TEXT("SpawnPoint"));
SpawnPoint->AttachParent = RootComponent;

I haven’t run into this with creating other actors exactly like that previously. It seems to only do it with the UArrowComponent and UTextRenderComponent. Looking at the documentation for both suggests that the code should work fine. Any help would be greatly appreciated.

This error means that SpawnPoint is a pointer to a generic data (with no members).

Do you have any other local variable call SpawnPoint in the code ?

No. That is the only place that variable is used.

Wierd. In my class It is not necessary.

Solved it. It seems like the ArrowComponent header has to be explicitly included. I find that rather odd, but it works now.

Thanks! I had the same issue and include the header file resolved it.

I had same issues several times, and it seems that’s the solution