How do I pass in variables through GEngine->AddOnScreenDebugMessage

Hello, I am trying to pass in a variable to GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, TEXT(“Can Enemy Shoot?”)); So how do i pass in a bool or a float?

Use FString::Printf to format your message. It functions the same as UE_LOG.
Format booleans as integers with %i

bool b = true;
float f = 1.42f;
FString s = "blabla";
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, FString::Printf(TEXT("Can Enemy Shoot? %i %f %s"), b, f, *s));
2 Likes

Thank you!!!