GEngine->GetWorld shouldn’t be returning null. That seems off. You could store a static pointer to your Hero (assuming there’s only one) on your game mode and then create a static method to grab it. Basically use a singleton-esque model.
class AMyGameMode : public AGameMode
{
static void SetActiveHero(AActor* MyHero) { s_MyHeroPtr = MyHero; }
static AActor* GetActiveHero() { check(s_MyHeroPtr.isValid()); return s_MyHeroPtr.Get(); }
// ...
private:
static TWeakObjectPtr<AActor> s_MyHeroPtr;
}
Then when your Hero is created, simply call AMyGameMode::SetActiveHero, and in your Console method you can call AMyGameMode::GetActiveHero.
Or figure out why GEngine is returning a null world and go about things that way.