Download

Can't display on Screen Debug Messages -- "GEngine is undeclared identifier"

Hi There!

I’m quite a Beginner at C++, so my problem could be really trivial. I’m workin on a Mac using XCode.

I created an Actor, which detects if an object is passing through a Sphere. To see if this works out I tried the Quick tip print with a print() Makro found here:

So my Code looks as follows:


/ Fill out your copyright notice in the Description page of Project Settings.

#include "minimaladvvehicle.h"
#include "Lightswitchtry4.h"
#include "UnrealEngine.h"

//DirtyDebug Makro
#define print(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 1.5, FColor::Green,text)

//.. some Code

// ... Object passes through Sphere

print("Object passed")



I get a Warning saying “Use of undeclared Identifier GEngine.”

In the Documentation nothing is said about declaring the GEngine Identifier in the header file of the cpp where I use it.

I tried to include the UnrealEngine.h in the .cpp and the .h of my Actor but that didn’t helped.

Do I have to declare GEngine in the headerfile of my Actor? If so how do i do that?

I tried the following:

In the headerfile of my Actor I made the following delcaration:


//This is a bad idea
UPROPERTY()
UEngine* MyGEngine

and replaced GEngine with MyGEngine in the print Macro of the cpp.

The build was successful but the Engine crashed as soon as my Object reached the actor. (At least I know my actor works).
So this can’t be right. The documentation and every C++ Tutorial Dealing with onScreen Debug Messages just uses the GEngine Identifier in the cpp file without any declaration in the headerfiles or somewhere else.

What am I missing? :confused:

I think you need to include Engine.h

Jepp. That solved the issue. Thanks! :slight_smile: