Another GetWorld() problem... (NULL when taken from outer when outer is derived)

Hello,

so I’m not here to describe the same issue as you can find here. Basically I have created a class derived from UObject and given an instance of it to my default gamemode class. It is created inside the gamemode constructor.

That object needs a world to spawn some objects at times. So it overrides ‘GetWorld()’ and returns ‘GetOuter()->GetWorld();’. This means it will call ‘GetWorld’ on its outer which is the gamemode. This works fine when I use those classes like that.

The problem arises when I create a blueprint derived from my gamemode. Anytime the inner object tries to call ‘GetWorld’ it gets a NULL value. I don’t understand why as it will still call ‘GetWorld’ on the blueprint gamemode. Why would that fail ?

By the way when debugging the “outer” is of the base class type it says. So blueprints are not recognized as classes and do not appear as “outer” ? How should I get the world there then ?

Also I tried a suggestion that was to do this:

TObjectIterator<AActor> Itr;
if (!Itr) return NULL;
return Itr->GetWorld();

And well… I got everything working in the editor and not in the game ugh. So when I stopped playing all the objects that should have spawned instantly spawned inside the editor…

Thanks in advance !