One thing that really comes handy during debugging is being able to send messages to yourself say in a log window or the game screen even. You may for instance want to know what data your actor is operating on. This is really easy to do in Unreal Engine.
To send messages to the console:
UE_LOG(LogTemp, Log, TEXT("Sample debug %s."),"message");
LogTemp is the default category for temporary log messages.
Log represents ordinary log messages that will be shown in grey. You have the option from:
- Log (grey)
- Warning (yellow)
- Error (red)
The last two parameters represent the log message format and arguments. Optionally you can you the format as the actual log message.
To send a message to the game screen:
GEngine->AddOnScreenDebugMessage(-1, 15, FColor::Red, "Sample debug message.");
You make use of GEngine to log messages to the screen by calling AddOnScreenDebugMessage. The first parameters is a key (-1 represents messages that can be repeated each shown individually, inverse being key 0). The second parameter is the number of seconds to display the message for. The third parameter is an FColor representing the color you would like to show the message in. The last parameter is the debug message you would like to show.
There is one disadvantage to sending messages to the game screen. These messages are displayed for a limited amount of time and you cannot go back to review these messages at a later stage.