Download

How can I check variables before starting?

I need to set a reference to the game object for my mobs before the game is starting. If the variable isn’t set, the game is crashed at the start because the object refers to it in Tick() method whereas here is nullptr. I tried to do a check at the start with the exit from the game if it isn’t set, but my method does not work. Am I doing the correct check or are there ready-made solutions for this case?

void ThrowError(const FString Message)
{
	GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, Message);
	FGenericPlatformMisc::RequestExit(false);
}