How to pass an INT into TextRender function?

How can I have a UTextRenderComponent change/update itself properly in a networked environment using an INT?

I have an INT variable similar to a Score like variable that I’d like to have displayed on the wall whenever the INT changes. I am stuck with the implementation and also the proper syntax to work with the textrender as I am not sure if the conversion from an INT to text is right.

Here is what I have.
.h

UPROPERTY(Replicated)
int32 CountUp;

PROPERTY(VisibleDefaultsOnly, BlueprintReadOnly, Category = Counter)
		TSubobjectPtr<UTextRenderComponent> Counter;

void DisplayText();

.cpp

(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
Counter = PCIP.CreateDefaultSubobject<UTextRenderComponent>(this, TEXT("Counter"));
if (Counter!= NULL)
{
		Counter->Text = TEXT("XX");
}
}

void ACheckDart::OnRep_Countup()
{
	DisplayText();
}

void ACheckDart::DisplayText_Implementation()
{
	Counter->Text = FString::Printf(TEXT("%i"), int32(CountUp));
}

void ACheckDart::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME_CONDITION(ACheckDart, CountUp, COND_InitialOnly);
}

Have u tried %d instead of %i in your Printf statement. So the following should work:

Counter->Text = FString::Printf( TEXT( "%d" ), CountUp );

Thanks I think its the replication that’s maybe wrong

The most concise way is actually

FString::FromInt(9000);

In case you ever want it to look prettier in code :slight_smile:

Rama