Debug message crashes engine

GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, “Code Fire”);
This line crashes the engine no matter where it is exectuted

GEngine is not always available, and calling AddOnScreenDebugMessage may cause a crash if that is the case.

If you enclose it with this if clause, it should be fine:

if (GEngine)
    GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, "Code Fire");

It worked a few minutes ago. I commented it out compiled removed the comment and it crashes.
And GEngine should be available in the context

Huh, strange. Well, Epic seems to be on the case! :smiley:

Hi -

Thank you for your report. We have assigned this issue to a member of our support staff, and they will begin investigation as soon as possible. If we are unable to reproduce the issue, or we need additional information, our staff member will comment here with additional questions. Otherwise, we will post an ‘Answer’ once we have logged the issue in our bug database or we have a solution for it.

In the meantime, please be sure to review our suggestions for how to report a bug, and feel free to edit your post if you have additional information to provide:

Thank you -

Eric Ketchum

Thats a default message.
it comes with every bug report

Hey -

is correct that you need to check that GEngine is available with the if(GEngine) block. However you also have to make sure that the class you’re using this in knows what GEngine is by including Engine.h. Additionally you want to add TEXT() around the text that is to be printed. Let us know if this code is still causing crashes for you.