(4-27) cant get the correct value while using GEngine->AddOnScreenDebugMessage()


I am trying to add a lean function to my c++ project, after calculating the YawDelta I want to displayed to my screen using the GEngine->AddOnScreenDebugMessage()

the problem it’s always 0 in the viewport screen when pressing play

here is my c++ code of the Lean function which is called in UpdateAnimationProperties (Tick)

void UShooterAnimInstance::Lean(float DeltaTime)
	if (ShooterCharacter == nullptr) return;
	CharacterYawLastFrame = CharacterYaw;
	CharacterYaw = ShooterCharacter->GetActorRotation().Yaw;

	const float Target{ (CharacterYaw - CharacterYawLastFrame) / DeltaTime };
	const float Interp{ FMath::FInterpTo(YawDelta, Target, DeltaTime, 6.f) };
	YawDelta = FMath::Clamp(Interp, -90.f, 90.f);

	if (GEngine) GEngine->AddOnScreenDebugMessage(5,
		FString::Printf(TEXT("YawDelta : %f"),

PS: if I use UE_LOG, the output log shows the variable 2 times, one with the correct value and the other one is always 0


Please help

since its not in blueprints i cant help much, but the issue you’re having is the server knows its side of the value where its set and you’re trying to load up the clients side value to view on your screen, which isnt replicated so its default is 0. If you know how to set your value that you are trying to call to, to view, go ahead and set it to replicated so when you grab it in client side widget its already been replicated from the server to the client.

This is why you see 2 values. 1 is the server’s version of your client and the other is the client side.