Issues Creating TextRender Component

Header:

class FE_API AFEObject : public AActor
{
	GENERATED_UCLASS_BODY()
	
	UPROPERTY(VisibleDefaultsOnly, Category = Object)
	TSubobjectPtr<class UCapsuleComponent> Capsule;

	UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
	TSubobjectPtr<class USkeletalMeshComponent> Mesh;

	UPROPERTY(VisibleDefaultsOnly, Category = Text)
	TSubobjectPtr<class UTextRenderComponent> FloatingText;

};

CPP:

AFEObject::AFEObject(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{

	Capsule = PCIP.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("Capsule"));
	this->SetRootComponent(Capsule);

	Mesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("ObjectMesh"));
	Mesh->AttachParent = Capsule;

	FloatingText = PCIP.CreateDefaultSubobject<UTextRenderComponent>(this, TEXT("ObjectMesh"));

}

The error is:

error C2439: ‘TSubobjectPtrConstructor::Object’ : member could not be initialized

error C2440: ‘initializing’ : cannot convert from ‘UTextRenderComponent *’ to ‘UObject *’

I checked the docs and it says UTextRenderComponent is a UObject, so I don’t understand what the problem is.

It probably has something to do with your includes. Are you using EngineMinimal.h or Engine.h in your FE.h file? Using the latter one might solve your problem.

Additionally, you named your Mesh and FloatingText the same which will cause issues when launching.