I have a custom component that inherits from USceneComponent called BallIndicatorComponent, which contains an IndicatorArm and an IndicatorMesh that’s attached to the arm. The setup for this class is below:
BallIndicatorComponent.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = BallIndicator)
class USpringArmComponent* IndicatorArm;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = BallIndicator)
class UStaticMeshComponent* IndicatorMesh;
BallIndicatorComponent.cpp Constructor
IndicatorArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("IndicatorArm"));
IndicatorArm->AttachTo(this);
IndicatorArm->TargetArmLength = 150.0f;
IndicatorArm->bUsePawnControlRotation = false;
IndicatorArm->SetHiddenInGame(false);
IndicatorMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("IndicatorMesh"));
IndicatorMesh->AttachTo(IndicatorArm);
IndicatorMesh->bOnlyOwnerSee = true;
IndicatorMesh->SetSimulatePhysics(false);
IndicatorMesh->SetCastShadow(false);
And in the Actor using the component, the setup is as follows:
MyCharacter.h
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = BallIndicator)
class UNSPBallIndicatorComponent* BallIndicatorComp;
MyCharacter.cpp Constructor
BallIndicatorComp = CreateDefaultSubobject<UNSPBallIndicatorComponent>(TEXT("BallIndicatorComp"));
BallIndicatorComp->AttachTo(RootComponent);
Here’s the problem: When I go to edit the blueprint derived from MyCharacter, the IndicatorMesh never shows up in the viewport. It shows up in the Components panel though, and the arm gets rendered in the viewport if I click on it in the Components panel. Here’s pictures describing what I’m seeing.
If I just have a SpringArmComponent and StaticMeshComponent in MyCharacter.h and add it in MyCharacter.cpp the same way I do so in BallIndicatorComponent.cpp, the mesh shows up.
Is there something I’m doing wrong, or is this a bug?