Strange behavior when accessing the HUD from a character's tick function ?

Hi,

Sorry about the large post, it’s kind of a complicated scenario.

My character is throwing dice and i want the total in real time in the HUD.

I have setup this simple tick code in the character’s cpp file:

void AYagPlayer::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	if (GEngine)
	{
		RealTimeDiceTotal = 0;
		for (int32 d = 0; d < DiceArray.Num(); d++)
		{
			RealTimeDiceTotal += DiceArray[d]->YagDiceResult;
		}
		AYagHUD* ThisHUD = (AYagHUD*)GetWorld()->GetFirstPlayerController()->MyHUD;
		ThisHUD->YagDiceTotalWidget->SetText(FText::FromString(FString::FromInt(RealTimeDiceTotal)));
	}
}

Problem: this works well for all the clients excepts for the last one and the server:

  • the last client always updates both its own HUD and the servers HUD
  • the server updates nothing

I have made tests: the server knows its own RealTimeDiceTotal (and can display it with other methods) and doesn’t know the client’s one. So it’s only a problem of HUD display as far as i can say.

Now here is the fun part. If i put the two HUD lines

AYagHUD* ThisHUD = (AYagHUD*)GetWorld()->GetFirstPlayerController()->MyHUD;
ThisHUD->YagDiceTotalWidget->SetText(FText::FromString(FString::FromInt(RealTimeDiceTotal)));

anywhere else in the code, they work well, the last client updates its own HUD only, and the server writes its own HUD (of course i then loose the realtime displaying, but that’s normal).

But as soon as those two lines come back in the tick function, then the last client and the server seem to share the last client’s HUD for this displaying.

I tried to put those lines in a function and call it from the tick function, same problem.

Maybe the picture will help: you can see all the clients have their total (upper right) to zero, which is normal, they didn’t throw dice.

The last client displays the correct total (9, as you can check on the dice), but the server displays it too.

The fact that the displaying HUD depends on its call from the tick function makes me think of a bug, so i post it here, sorry if i am wrong.

Thanks

Hi ,

A few clarification questions for you.

  • What version of the Engine are you using?
  • Are you using the binary version from the Launcher, or did you build the Engine from source code?
  • Is this only happening in your project, or are you able to reproduce it in a new project? If so, can you provide the exact steps you are following to set this up?

Hi ,

We have not heard from you for some time. Is this issue still affecting you? I will be marking this issue as resolved for now, but if you still need any help with this please feel free to re-open this issue.