Will meta = (WorldContext = "WorldContextObject") work in build version of my game?

Hello,

I have a BlueprintCallable cpp function that needs to have world context to be able to run and since GetWorld() functions are not static I can not use them.

I searched through the question and found out that I can send the world from the blueprint node to my BlueprintCallable function by adding meta = (WorldContext = "WorldContextObject") however, when I checked the unreal engine documentation, there was something written, about meta being only usable inside of the editor, and I’m thinking, that means, if I use this line in my code, when I build the game, it’s not going to work. but, still, so many people recommending this line to get the world in blueprint without mentioning anything about it not being able to run in the build version.

my questions are:

  1. Do you know if that’s going to work
    in the build version or not?
  2. have you tried that?
  3. If It doesn’t work in build version,
    is there any other way to get the
    world in blueprint node and send it
    to the BlueprintCallable functions?
  4. if not, do you know how to get world
    inside of a static cpp function?

Thanks for reading my question,

Best regards

  1. It will work
  2. Yes
  3. N/A
  4. GEngine->GetWorldFromContextObjectChecked(WorldContextObject);

Yes, the meta stuff is only for the Editor, however, the Blueprint only is compiled in the editor, and the WorldContextObject is just part of the compilation. So, although it is not technically in the packaged build, it works perfectly because the blueprint is already compiled.

Hope this helps!

1 Like

Also, if you look in the Engine code, WorldContext meta is used constantly; it is used to make UGameplayStatics::SpawnEmitterAtLocation work in BP, for instance.

thank you so much for the detailed answer, I really appreciate that.