The following may not be entirely accurate anymore since its been a while I look into this. From what I remember function libraries need a “World Context” object (hidden function input), essentially any UObject
that implements GetWorld
. Actors, ActorComponents and a few other classes implement GetWorld
accordingly so these can use the function library functions. All classes that directly inherit from UObject
have the default implementation of GetWorld
(following the outer-chain). However this default implementation is not considered “valid” because the class does not explicitly override GetWorld
resulting in functions requiring a “World Context” object not being callable.
There are two solutions I’m aware of (unfortunately both involve some native code):
- either create a C++ class derived from UObject where you implement
GetWorld
in a valid way. You can find a couple of examples for this if you look at existingGetWorld
implementations from the engine itself. This will make the function library functions callable again in classes inheriting this new class. For some reason the “World Context” object pin will be visible and must be connected manually though (unlike Actors, Components, etc.). Using aSelf
node is sufficient for that though. - create an empty C++ class derived from UObject and add
meta=(ShowWorldContextPin)
in theUCLASS(...)
macro. The function library functions should be callable again for classes derived from this new class. And as the name of the metadata suggests the “World Context” object pin will also be visible here and must be connected manually. Since the object itself may or may not have a valid way toGetWorld
(depending on the outer) you need to decide whether you can passSelf
or another object as the “World Context”