World context object

You can create UObject base class in C++ with:

UCLASS(BlueprintType, Blueprintable, Abstract, Meta = (ShowWorldContextPin))
class YOURGAME_API UObjectWithWorldContext : public UObject

and then make your BP Objects children of it
Meta = (ShowWorldContextPin) will make all, normally hidden, WorldContext pins visible, and You can provide an object with WorldContext Yourself, being able to use any functions from inside Classes derivated from this class.
Otherwise the WorldContext pin is hidden and You cannot connect anything to it, even if Your object has reference WorldContext, or has a field that has one (e.g. it has an Actor reference that You set during construct/ or in some custom init function)

When creating an object You have to provide the “Outer” object. If this outer has access to the world (You used actor/ actor component / object that already had world context), then You can just connect self when calling those functions as Your object actualy already has oaccess to the world (GetWorld function returns Outer->GetWorld(), if the object don’t have the world set, so it will work just fine if at least the outer object has the world reference).

TBH, probably 99% of objects You usually create by Yourself will have reference to the world anyway, but blueprints won’t let You even let You try by default because of some edge case where You created an object using a game instance as the outer or something like that :man_shrugging:

6 Likes