Im using new Unreal Engine 5 Preview 2 and I don’t know if it’s a bug, but I get duplicate CameraComponent in my character blueprint when using SetupAttachment() in my MainPlayer.cpp. Is this new system ? Or a bug ? If it’s new system, can anyone explain what changed ?
MainPlayer.h
// Camera Component
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
TObjectPtr<UCameraComponent> CameraComponent;
}
MainPlayer.cpp
// Sets default values
AMainPlayer::AMainPlayer(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
SpringArmComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComponent"));
// Setup hierarchy of components in blueprint
CameraComponent->SetupAttachment(SpringArmComponent);
SpringArmComponent->SetupAttachment(GetRootComponent());
}
Blueprint