Book Image

Learning C++ by creating games with UE4

By : William Sherif
Book Image

Learning C++ by creating games with UE4

By: William Sherif

Overview of this book

Table of Contents (19 chapters)
Learning C++ by Creating Games with UE4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Variables and Memory
Index

Debugging the output in UE4


All of the code in this chapter (as well as in the later chapters) will require you to work in a UE4 project. For the purpose of testing TArray, I created a basic code project called TArrays. In the ATArraysGameMode::ATArraysGameMode constructor, I am using the debug output feature to print text to the console.

Here's how the code will look:

ATArraysGameMode::ATArraysGameMode(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
  if( GEngine )
  {
    GEngine->AddOnScreenDebugMessage( 0, 30.f, FColor::Red,  "Hello!" );
  }
}

If you compile and run this project, you will see the debug text in the top-left corner of your game window when you start the game. You can use a debug output to see the internals of your program at any time. Just make sure that the GEngine object exists at the time of debugging the output. The output of the preceding code is shown in the following screenshot: