How do you access "World Settings" variables in blueprint event graph?

Let’s say I wanted to access the “GlobalGravityZ” variable from “World Settings” which, if you look at the source code, is a UPROPERTY with the specifier BlueprintReadOnly. So lets say I’m on the level blueprint event graph. How would I go about reading this variable from world settings?

There currently no way to get WorldSettings in blueprint, you need to make your own node which will get AWorldSetting using this function:

AWorldSEtting got UPROPERTsY due to fact world settings menu is simple defaults property viewer of AWorldSetting which are saved with level (in fact you can actully modify it, in project settings you can change AWorldSettings class), i guess BlueprintReadOnly might be copy-paste mistake or to make it future proof in case world setting will be accessable from blueprints

Thanks for the answer. I am pretty new to UE4 and need some clarification. Do you mean make my own function/node in the UE4 source code that uses the GetWorldSettings function or is there a way to do that without modifying the source code?

No, you can do that from your game module without modifying the source code :slight_smile: Engine is devided in to modules which are compiled to dll and can be dynamicly loaded and unloaded in runtime (similar to Linux kernel). When you create C++ project or a plug-in you create your own module and that module has same capabilities as any other engine module, you practicly extending engine code. So all you need to do is create a C++ class (you can extend AWorldSettings too) and in it static function (static function does not require object instance, and own’t have “Target” input in blueprint) that will look like this:

in h in class decleration:

UPROPERTY(BlueprintCallable, Category="World Settings")
static AWorldSettings* GetWorldSettings();

in cpp:

AWorldSettings* GetWorldSettings() {
        if(GEngine) return GEngine->GetFirstLocalPlayerController()->()->GetWorldSettings();
        return nullptr;
}

We nee so long control because from static it’s hard to get UWorld, there GWorld which is UWorld global pointer but i’m not 100% sure if it gonna give you PIE World not Editor world (the world you edit in, each 3D view in editor has it own world) if you use it editor, you can try it by replaceing if line with:

if(GWorld) return GWorld->GetWorldSettings();

All you need is “Get All Actors of Class” with class “World Settings” and get 0 actor from it. After that disable Context Sensitive and type “World Settings”. Although you can only “Get” it but not “Set”.

Ah I see. Thank you very much. Just so I am clear though, is Arida 's answer wrong? I tested it and it seemed to work.

O thank you. How did you know there was a WorldInfo at the head of the array returned by GetAllActorsOfClass though? This doesn’t seem like the intended use of this function. I am new to UE though so I could be dead wrong.

Well for me it seems pretty obvious, since WorldSettings class is one of the “core” classes that must exist during runtime (like GameInstance). And since its Actor class we can get actor from scene with Get All Actor Of Class. And since there will be only one actor, it will be at 0. Just because we don’t have shortcut like Get World Settings doesn’t mean we can’t access it.

For example Get Player Character:

And “hard” way to do same with WorldSettings: