Hi everyone,
I’ve been working on a project in Unreal Engine and ran into an issue when trying to add a SphereComponent
via an ActorComponent
. While the SphereComponent
is visible in the viewport, it doesn’t appear in the Components tab of the Blueprint Editor.
Here’s a summary of my setup:
MyActorComponent.h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MyActorComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MYPROJECT_API UMyActorComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UMyActorComponent();
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
class USphereComponent* Collider;
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
};
MyActorComponent.cpp
#include "MyActorComponent.h"
#include "Components/SphereComponent.h"
// Sets default values for this component's properties
UMyActorComponent::UMyActorComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
Collider = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere"));
if (AActor* Owner = GetOwner())
{
Collider->SetupAttachment(Owner->GetRootComponent());
Collider->RegisterComponent();
}
}
// Called when the game starts
void UMyActorComponent::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UMyActorComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
and this is what happen:
Despite these steps, the SphereComponent
is only visible in the viewport but not listed in the Components tab.
I also tried google and found some threads saying it’s a UE 4.x bug
but I’m using UE 5.4.4
Any insights or suggestions on what might be missing or misconfigured would be greatly appreciated!
Thank you!