You have one other possible solution (since you can’t always just jam functionality on the game instance):
Your class can override UObject::GetWorld
so that it returns the world that is relevant to your object. This is one of those weird cases where you shouldn’t call Super::
in your implementation. If you do the engine treats it as if you didn’t override it and the blueprint won’t think that self/this is a valid input for WorldContext pins.
One implementation of this that I’ve seen (but don’t really like) is for your class to have a WorldContext member variable that is set before calling blueprint implementable functions. Then the override of GetWorld
can just return that value.
It has a number of limitations (and like I said I don’t really like it as a solution that much) but it is very direct.