Hi am trying to convert a blueprint (Default scene + 2 Text render components) into cpp.
In my blueprint,
The default scene scale is 1,1,1
The first Text Render Component scale is 1,1,1 with XScale=0.5, YScale=0.5 and WorldSize=26
The second Text Render Component scale is 1,1,1 with XScale=1, YScale=1 and WorldSize=26
Now when for my cpp I have:
AInGameTextMainSystem::AInGameTextMainSystem()
{
// 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;
// ...
//Initialize components
//Create the Scene Component and set it as the root component
DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
DefaultSceneRoot->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));
RootComponent = DefaultSceneRoot;
// *********************************
// *** Setting Round number text ***
// *********************************
UTRC_RoundNumber = CreateDefaultSubobject<UTextRenderComponent>(TEXT("UTRC_RoundNumber"));
UTRC_RoundNumber->SetupAttachment(RootComponent);
// Optionally, set some default properties
UTRC_RoundNumber->SetText(FText::FromString(TEXT("Round 1/10")));
UTRC_RoundNumber->SetHorizontalAlignment(EHTA_Center);
UTRC_RoundNumber->SetVerticalAlignment(EVRTA_TextCenter);
//UTRC_RoundNumber->SetWorldScale3D(FV_RoundNumber);
static ConstructorHelpers::FObjectFinder<UMaterial> UM_RoundNumberMaterial(TEXT("/Game/GameInfo/AudioWide_M_TEST3.AudioWide_M_TEST3"));
if (UM_RoundNumberMaterial.Succeeded())
{
UM_RoundNumber = UM_RoundNumberMaterial.Object;
UTRC_RoundNumber->SetMaterial(0, UM_RoundNumber);
}
else
{
UE_LOG(LogTemp, Error, TEXT("UM_RoundNumberMaterial NOK"));
}
static ConstructorHelpers::FObjectFinder<UFont> UF_RoundNumberFont(TEXT("/Game/Menus/fONT/FG_AudioWide/FG_Audiowide-Regular_Font.FG_Audiowide-Regular_Font"));
if (UF_RoundNumberFont.Succeeded())
{
UF_RoundNumber = UF_RoundNumberFont.Object;
UTRC_RoundNumber->SetFont(UF_RoundNumber);
}
else
{
UE_LOG(LogTemp, Error, TEXT("UF_RoundNumberFont NOK"));
}
// Set the text render color
UTRC_RoundNumber->SetTextRenderColor(FColor::White);
f_RoundNumberXScale = 0.5f;
f_RoundNumberYScale = 0.5f;
f_RoundNumberWorldSize = 26.0f;
FV_RoundNumberLocation = FVector(0.0f, 0.0f, -100.0f);
UTRC_RoundNumber->SetXScale(f_RoundNumberXScale);
UTRC_RoundNumber->SetYScale(f_RoundNumberYScale);
UTRC_RoundNumber->SetWorldSize(f_RoundNumberWorldSize);
UTRC_RoundNumber->SetRelativeLocation(FV_RoundNumberLocation);
UTRC_RoundNumber->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));
// *********************************
// *********************************
// *** Setting Score number text ***
// *********************************
UTRC_Score = CreateDefaultSubobject<UTextRenderComponent>(TEXT("UTRC_Score"));
UTRC_Score->SetupAttachment(RootComponent);
// Optionally, set some default properties
UTRC_Score->SetText(FText::FromString(TEXT("0 : 0")));
UTRC_Score->SetHorizontalAlignment(EHTA_Center);
UTRC_Score->SetVerticalAlignment(EVRTA_TextCenter);
//UTRC_Score->SetWorldScale3D(FV_Score);
static ConstructorHelpers::FObjectFinder<UMaterial> UM_ScoreMaterial(TEXT("/Game/GameInfo/AudioWide_M_TEST3.AudioWide_M_TEST3"));
if (UM_ScoreMaterial.Succeeded())
{
UM_Score = UM_ScoreMaterial.Object;
UTRC_Score->SetMaterial(0, UM_Score);
}
else
{
UE_LOG(LogTemp, Error, TEXT("UM_ScoreMaterial NOK"));
}
static ConstructorHelpers::FObjectFinder<UFont> UF_ScoreFont(TEXT("/Game/Menus/fONT/FG_AudioWide/FG_Audiowide-Regular_Font.FG_Audiowide-Regular_Font"));
if (UF_ScoreFont.Succeeded())
{
UF_Score = UF_ScoreFont.Object;
UTRC_Score->SetFont(UF_Score);
}
else
{
UE_LOG(LogTemp, Error, TEXT("UF_ScoreFont NOK"));
}
// Set the text render color
UTRC_Score->SetTextRenderColor(FColor::White);
f_ScoreXScale = 1.0f;
f_ScoreYScale = 1.0f;
f_ScoreWorldSize = 26.0f;
FV_ScoreLocation = FVector(0.0f, 0.0f, 0.0f);
UTRC_Score->SetXScale(f_ScoreXScale);
UTRC_Score->SetYScale(f_ScoreYScale);
UTRC_Score->SetWorldSize(f_ScoreWorldSize);
UTRC_Score->SetRelativeLocation(FV_ScoreLocation);
UTRC_Score->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));
// *********************************
}
Which results in:
I don’t manage to understand why they are different in scale. If you think you know why please tell me (Please note the result is the same even if I drop all the SetRelativeScale3D)