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.