Print debug messages to screen - from C++

Hi Guys,
In these courses we use a lot of UE_LOGs and Blueprint String Printing functions.

  • UE_LOG prints to the console output
  • Blueprint prints to the screen (and optionally to the console output).

Here’s how to print to the screen from C++ (which is a must if you are doing VR because you can’t see your output logs from the headset)

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(
                          -1,        // don't over wrire previous message, add a new one
                          0.35f,   // Duration of message - limits distance messages scroll onto screen
                          FColor::Cyan.WithAlpha(64),   // Color and transparancy!
                          FString::Printf(TEXT("        %s: %s"),*HitName, *HitLocation.ToString())  // Our usual text message format
                     );
	}

GEngine is ALWAYS available (It’s GLOBAL, hence the beginning “G”).

Hope someone else finds this useful!

1 Like

Excellent work. Thank you for taking the time to share this with others.

Privacy & Terms