I’m not sure if this is inteded, anyway i created a blueprint function library, with functions declared like this one:
UFUNCTION(BlueprintCallable, Category = Game, meta = (WorldContext = "WorldContextObject"))
static class AImperoCharacter* SpawnUnitFromClass(class UObject* WorldContextObject, TSubclassOf<class AImperoCharacter> UnitClass, const FVector& SpawnLocation, const FRotator& FaceDirection, int32 OwnerNumber);
They appears as usually if i’m building a graph in a AActor-derived blueprint, instead they don’t appear even if i disable the context option if the blueprint is an UObject-derived one.
Sorry for the delayed response to your post. I did some testing on this and noticed the results that you described. It appears to only happen when using
meta = (WorldContext = "WorldContextObject"), though. I have submitted a report of my findings to have this investigated further (UE-15683).
Any update on this? This appears to be the case with Blueprint defined BlueprintFunctionLibraries as well, i.e. I have a BlueprintFunctionLibrary I created in blueprint and another UObject derived blueprint cannot call functions inside of it.
I checked the status of the ticket I had entered, and it is still open. Unfortunately we do not have any estimate for when it will be resolved. However, I did add the additional information that you provided to the ticket.
I solved using Actors blueprints or not using WorldContext.
Still have the same issue - can’t access function libraries from Object-derived blueprints. Engine version 4.12.
This should really be fixed by now
Our test case for this issue was fixed in 4.9. Could you please provide some more information about the issue you are seeing and how we can reproduce it?
Well, removing the meta now it works.
But with it, nodes still aren’t showing up.
-create a new BlueprintFunctionLibrary
-create a new function, even empty, like this one:
UFUNCTION(BlueprintCallable, Category = "MyGame", meta = (WorldContext = "WorldContextObject"))
static void SpawnMovementParticle(class UObject* WorldContextObject, FVector Location);
-create a new blueprint with UObject as parent
-try to use that function in the blueprint: it shows only if we remove the meta tag
Thanks for the clarification. I narrowed it down to find that it is only occurring when the function takes in a UObject parameter named
WorldContextObject, in this instance. I have updated the ticket for this issue with the new information.
How is this resolved? I’m not using C++, so I don’t see anything about a WorldContextObject. How do you make it work with Function Libraries made in the editor?
I was not able to reproduce the issue using a Blueprint Function Library created in the Editor. Do you have any specific examples that do not work for you?
Also, you can check the status of this issue here.
Could we remove the “meta = (WorldContext = “WorldContextObject”)” from the blueprint library functions? This would address most of my issues.
The behavior that I observed happening here would only occur when a UObject reference was passed to the function using the same name as what was defined in the UFUNCTION’s metadata. This tells the function to automatically use a reference to the World for whatever called the function. If it was an Actor that called the function, this works fine. However, for UObjects there is no guarantee that the calling object is even present in a World, so it won’t work. I dug a little bit deeper into this area and I am starting to think that this is actually intended behavior (the report that I originally submitted is still backlogged, so there may actually be something wrong here).
There are a couple ways that you can get around this, though. Both require that the UObject class where you will be calling the function be a custom code class. The first option is to implement an override for the
GetWorld() function in your UObject class. With this function implemented, any Blueprint that you make from this base class will assume that you are getting the correct World, and the
World Context Object pin will be exposed on the node for you to plug into.
The other option is to include
meta = (ShowWorldContextPin) in the UCLASS specifier list for your UObject class. This will also make the
World Context Object pin visible for you to plug into.
The first option is preferred, since you can make use of the UObject method
ImplementsGetWorld() but it does imply that the object is tied to a specific World and has a well-defined way to identify that World. Keep in mind that with both of these options, you are losing the safety net of the Engine’s automatic process for specifying the World Context Object. You are essentially telling the Engine that you know what you are doing and are taking responsibility for making sure it works. In both cases, you must be able to plug a valid World Context Object into the pin in order to be able to compile the Blueprint.
Hi, sorry for necroing. Implementing GetWorld() in my base worked perfectly fine. But this took way too long to find.
I understand the reasoning behind why this is needed, but would be very nice if it could be added to the documentation somewhere. I couldn’t find it mentioned anywhere. Maybe add a note for this on the WorldContext meta tag description.