Download

TextRenderComponent->SetText() doesnt work on network play

The above works perfectly fine when I run in single player. But it does absolutely nothing when I run it with more than one player, or with just dedicated server.

I would have thought it was replication issues, but it doesnt even work on the client. I know the rest of the code works, as my log messages show correct data. The function call to change the text is run on the character class itself and it still doesnt work, even when using SetText(FString(“Test”) it works single player, but does nothing otherwise.

So my question is, is the SetText call broken when the game is networked? Im not sure why it wouldnt at least work on the client for that specific character only, especially when the code is in the character class itself.

Right now, it just leaves it at the default text I set in the constructor.

(Oh by the way the call to this is being done after character possession, so its already in the world, and no pointers are broken, as I have all the checks.

Can you step into the method? Maybe you can get a hint to what’s causing the error.

Stepped through the code and according to the debugger, it actually changes the text. I can see the array size changing to the same params as whats passed into it.
But the rendering is never updated. I tried explicitly calling MarkRenderStateDirty() on the text render component and no change.

However, did run into more issues with it in that SetColor NEVER works. And I call it in the constructor of the character class. I just wanted it to be white and so coded in the defaults. In the editor, in my blueprints derived from the character classes it renders as white in the viewport preview, but as soon as I run it goes black. For client and others.

Even if you force it on the client, to rule out any replication issues? I’d love to test this myself if you can outline some steps I can take to reproduce the issue.

Yeah I did a hard code in each character class for on possess to give me a log message showing the input data and that all fires.

Debug showed the array size changing for the data value, but even on the client itself it never changes. RPC calls to the server do nothing for the clients in question, and nothing else.

It only seems to allow me to change the text in the constructor for the character class, anywhere else it fails when running any kind of multiplayer. Changing text color still broken even when setting in the constructor.

As for steps, it seems the Text Render Component was always broken. My character class had no issues, then just added in the code to add the component, and a minor amount of logic in it.

the .h



UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Player)
	class UTextRenderComponent* PlayerNameComponent;


in the constructor in the .cpp



	// The text for displaying our players name
	PlayerNameComponent = CreateDefaultSubobject<UTextRenderComponent>(TEXT("PlayerName"));
	PlayerNameComponent->AttachTo(RootComponent);
	PlayerNameComponent->SetText("Player Name");
	PlayerNameComponent->HorizontalAlignment = EHorizTextAligment::EHTA_Center;
	PlayerNameComponent->VerticalAlignment = EVerticalTextAligment::EVRTA_TextCenter;
	PlayerNameComponent->RelativeRotation = FRotator(0.0f, 90.0f, 0.0f);
	PlayerNameComponent->RelativeLocation = FVector(0.0f, 0.0f, 80.0f);
	PlayerNameComponent->XScale = 1.5f;
	PlayerNameComponent->YScale = 1.5f;
	PlayerNameComponent->SetTextRenderColor(FColor::White);
	//PlayerNameComponent->bOwnerNoSee = true; // Commented out for testing purposes


The Set Text here works perfect. All of my characters display “Player Name”

Now, before I had more logic to get a player name from the player state, etc. But when the issue popped up I changed it to this:



void ASideOpCharacter::PossessedBy(class AController* InController)
{
	Super::PossessedBy(InController);

	// Set the players Name Render Text

	// Cast our player controller
	ASideOpPlayerController* SideOpPC = Cast<ASideOpPlayerController>(InController);
	if (SideOpPC)
	{
		// Get our Player State
		ASideOpPlayerState* SideOpPlayerState = Cast<ASideOpPlayerState>(SideOpPC->PlayerState);
		if (SideOpPlayerState)
		{
			// Finally set the name
			// Normally, we would use a screenname here from steam or elsewhere.
			// For testing purposes, using my own
			//SideOpPlayerState->SetPlayerName(FString("Sharris")); // Set directly since its broken
			UpdateDisplayName(FString("TEST"));
		}
		else
		{
			GEngine->AddOnScreenDebugMessage(7, 10.0f, FColor::Green, TEXT("No PS"));
		}
	}
	else
	{
		GEngine->AddOnScreenDebugMessage(5, 10.0f, FColor::Green, TEXT("No PC"));
	}
}

void ASideOpCharacter::UpdateDisplayName(FString NewName)
{
	if (Role == ROLE_Authority)
	{
		PlayerNameComponent->SetText(NewName);
	}
	else
	{
		ServerUpdateName(NewName);
	}

	PlayerNameComponent->MarkRenderStateDirty();
	GEngine->AddOnScreenDebugMessage(7, 10.0f, FColor::Magenta, TEXT("Called the Update"));

}



It shows my log message saying the update function was called (And it didnt fail the checks for the PlayerState or the PC), and my debugging showed that the Text variable for my PlayerNameComponent is being changed, as the array size goes from its original size to the same size array as the string being pushed in. Just the rendering never seems to change. Even with it hardcoded into the character class, it still for all clients even the one thats focused, it never changes. But as soon as I turn it back to 1 player, and turn off the dedicated server, it works fine. Except the Color changing never works.

Ive tried using RPC just to make sure its not a replication issue, and without, and same functionality.

Just tried doing a BP version of the same and it fails. I just set it to where when the pawn is possessed, to change the text to “TEST”. Doesnt do anything until I go back to single player mode.

Did you find a solution to this?

I’m experiencing something similar in version 4.8.2.

I cant get it work either. It is still broken?

The function PossessedBy is only called on the server, therefore updating text would not reflect on any clients.

You could call a client RPC from the server to update text on the client.