So GetWorld() can be called in C++ for any UObject, but is there an equivalent in blueprint? I have some functions which take the world as an argument that I need to use but I can’t find a way to get a reference to it.
It’s a static function i wrote in C++ that needs the world
Generally, what is done is too pass a Uobject* as a first parameter named “WorldContextObject”, from which you can do “Getworld”. You can improve your flow in blueprints to pass automatically this Uobject, by doing :
UFUNCTION(BlueprintCallable, meta = (WorldContext=“WorldContextObject”))
static void MyFunction(UObject* WorldContextObject,…)
This is what is used from most of blueprint libraries in UE4. See GameplayStatics.h or KismetSystemLibrary.h for more examples.
Dude, thanks a lot!
This fundamentally doesn’t answer the question “How to get the current world from a blueprint.” I don’t want to pass in a world context object into a C++ function - I want to read the current world in blueprints and call GetOwner()->GetWorld() from within a blueprint graph. So that I can do Blueprint logic based on which world my current object is based on what world it’s currently being called from. This answer is not actually a solution.
There is a “get current level name” node you can call. Not sure if that would help at all