BlueprintCallable and TWeakObjectPtr

I have a method where I need to pass in an actor to get some information from said actor. This is also a method that I want to be able to use in blueprints, or rather let others use in blueprints. when I have a

UFUNCTION(BlueprintCallable, Category = Logic)

decorator above the method declaration in the header, the compiler goes nuts on me with the following error:

Error 1 error C2275: ‘TWeakObjectPtr<AActor,FWeakObjectPtr,FIndexToObject>’ : illegal use of this type as an expression

Is this something we’re not supposed to be able to do? And if so, is there a “proper” way of passing objects around by reference that would let me use the method via blueprints?

Where is the rest of your code?

You can’t give us just the one line :slight_smile:


There’s really not much more. The actual method prototype is as follows:

void SetParent(TWeakObjectPtr<AActor> parent);

When I have

UFUNCTION(BlueprintCallable, Category = Logic)

above it, the compiler craps out with the above error.

I can apparently do

void SetParent(AActor* parent);

and use a raw pointer, but apparently not a TWeakObjectPtr.

I’m encountering this problem too.
I guess that TWeakObjectPtr<Anytype> can’t be the parameter type of BlueprintCallable function, so you must use Anytype*?