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.