Creating blueprint function in class derived from UBlueprintFunctionLibrary vs AActor

What are cons and pros of doing in each of them ? Or more specific what is the scenario for creating in either of them ? How should I decide whether to create functions in Actor derived class Library derived ?

Is it that the Library should be used for more or less generic functions that I plan to use in many different class blueprints and functions defined within AActor hierarchy should be specific to the task performed by said actor ?

From what I see the biggest deal is that functions defined inside class derived from UBlueprintFunctionLibrary do not have default target input. As far as I can tell it’s actually quite a big deal for most functions.

Adding the function to the Actor allows you to override functionality in derived classes. It also keep the code organized with the Actor itself, and allows access to private members. In general both approaches will work in many cases!

The biggest advantage of Blueprint library functions in my opinion is that you can easily call them from any blueprint.

The biggest disadvantage of a Blueprint library is that all functions are static, so you must use ObjectIterator to get a reference to the world, and you do not have immediate access to any member variables of a specific class.

So if you needed a lot of blueprint nodes and access to member variables of a specific class, then you need to make those nodes in that class.

But if you are making generic functions you want to call anywhere, make a BP library

Now that it is easier for blueprints of specific classes to communicate your range of options is much expanded depending on the type of function you are coding

:slight_smile:

Rama