Hello! I’m wondering, if I have a behavior tree function, and I want to use it in a separate blueprint, can I call it in the other blueprint? Or do I need to copy everything in the behavior tree function and paste it into a regular function?
For context, I want to take this function:
Ideally, you can add this function to a “Blueprint Function Library” and then you can call that function from any blueprint. This helps to eliminate duplicated code spread everywhere. But not all nodes will be available inside a library. It’s worth a try.
Hey @Comicbook23! As LFA was saying if you’re trying to do all the same things as in that blueprint without copy and pasting it, the best way would be a blueprint function library and you could call it from anywhere!
That said, if you were attempting to call it on say another objects behavior tree to iterate on the other object, you’d have to cast to that object and tell it to execute it there.
Well, I would have to create an empty function in the library and then paste all the nodes from the already existing function into it, right? If I do that, there are two versions of the same function. And sometimes when I do that, it deletes nodes. Is this the only way to add a function to the library?
Most nodes that it deletes are specific to the type of class it comes from or a reference to something that is not in it’s purview, anything generalized that could work in any scene should be fine, some specifics could cause a problem in some instances.
In case of duplicates, you can replace the older function by the new one created in the library.
Also, nodes associated with time (delay, wait for task, move component to) will not work). You want to create a “Blueprint Macro Library” for those types of functions (select type “Actor”).
Functions that are class specific, such as Teleport, Add Pitch Input, etc, need to have the correspondent class as input so you can plug the nodes correctly. Depending on the function, also will not show up inside a library.
Oh, that’s really neat! I didn’t know you could make a class an input into the function.
That stinks that I can’t use Delay. I’ve been having a problem with that, so that explains why that’s happening.