Download

Where to get the WorldContextObject when World is null?

Hi,

As the subject says… it is only problematic when we are doing our things in C++. Ie in C++, GetWorld() returns null when the client cannot connect to server. Or should I open a level first?

Btw, in BP it is just straightforward - you can always execute openconsole (c++ ConsoleCommand) node even though no world is loaded. Seems so unfair lol. There must be something extra in BP that enable it do so.

Apologize if this sounds like a total noob question.

A valid WorldContextObject can be any actor or UObject afaik. AActor->GetWorld() should work fine?

Probably in different class yes (I forgot to write that) but here in from within inherited UGameEngine. However day suddenly turn brighter and I have got the solution the minutes I posted this… lol… I guess this will work regardless of the class you are working on:-



UWorld* World = GEngine->GetWorldContexts()[0].World();


2 Likes