C++ Scene Capture Component? Bug

I’ve made a scene capture component in c++ that should attach to a camera boom, but it doesn’t? It does attach to the root component but anything else it just craps out. It does however attach to the camera boom on run-time if i tell it to in the begin play function, so i don’t think its violating anything, It just doesn’t attach in the blueprint? I’ve had problems with camera booms for a while now and it seems like this bug is never fixed through out all unreal versions even after staff say they have told there team or sent a report.

here’s my code in the constructor:

CaptureCamera = PCIP.CreateDefaultSubobject<USceneCaptureComponent2D>(this, TEXT("CaptureCamera"));
CaptureCamera->AttachTo(CaptureBoom);

Hey AndrewM47-

Can you post the full class (header and source) for your scene capture component? I can tell you that PCIP has been depreciated and it is recommended that you use CaptureCamera = CreateDefaultSubobject(TEXT("CaptureCamera")); instead.

Cheers

CPP

ACustom_Character::ACustom_Character(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{

    	FirstPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("FirstPersonCamera"));
    	FirstPersonCameraComponent->AttachTo(RootComponent);
    
    	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
    	CameraBoom->AttachTo(GetMesh());
    
    	ThirdPersonCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("ThirdPersonCameraComponent"));
    	ThirdPersonCameraComponent->AttachTo(CameraBoom, USpringArmComponent::SocketName);
    	ThirdPersonCameraComponent->FieldOfView = 120.f;
    
    	CaptureCamera = CreateDefaultSubobject<USceneCaptureComponent2D>(TEXT("CaptureCamera"));
    	CaptureCamera->AttachTo(CaptureBoom);
    	
    	CaptureBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CaptureBoom"));
    	CaptureBoom->AttachTo(GetMesh());
}

Header

UCLASS()
class PROJECT_BASE_SYSTEM_API ACustom_Character: public ACharacter
{
	GENERATED_BODY()
	
	ABase_Character(const FObjectInitializer& ObjectInitializer);

	virtual void BeginPlay() override;
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent);

public :

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Replicated)
		class UCameraComponent* FirstPersonCameraComponent;

	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Replicated)
		class UCameraComponent* ThirdPersonCameraComponent;
		
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, Replicated)
		class USceneCaptureComponent2D* CaptureCamera;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
	class USpringArmComponent* CaptureBoom;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
	class USpringArmComponent* CameraBoom;

}

Hey AndrewM47-

In your source file you’re creating the CaptureCamera (scene capture component) and attaching it to your CaptureBoom (spring arm component) prior to creating the CaptureBoom. When the AttachTo is called it doesn’t know what the CaptureBoom is since it hasn’t been created yet. If you rearrange the code to create the CaptureBoom before creating the CaptureCamera then your hierarchy should be arranged as you would expect.

Cheers

Thanks that worked!