Question about blueprint function library.

Hello all!

I have a question about blueprint function(s) library.

If I use the same library from multiple blueprints at the time, all the blueprints will use/share the same variables, or they will have their own each?

Local variables - I hope a real programmer explains this better - are cleared from memory, or at least marked for reuse, and does not remember their values. Each call to any function with local variables will create its own local variables with the default values.

Memory for local variables is allocated and released when the variable comes in and goes out of scope.
Meaning a variable that is local to a BP function will be created when the function starts executing and destroyed upon return to the caller.
Similarly, a variable that is part of a blueprint (and thus local to the blueprint) will be allocated and destroyed togethr with the owing BP (actor).

Function library does not have GLOBAL variables, everything is local and survives only inside one function and during single function call. So every time you call that function it will have its own copy of variables.

However if you need some “global” variables, you may use game state blueprint, it is very easy to reference from about anywhere, it exists on clients and server. And you can store all “global” variables there, then make “get” and “Set” pure functions for them.

PS. one warning about function libraries: do not make multiple function libraries. This could be fixed by now, but i use it here as example of potential troubles. I created 2 function libraries (one was generic math stuff, other more game utility related), then my blueprint called generic function that called math function from different library. Then same blueprint called some math functions from math library. Result was all 3 modules had circular dependencies on each other. So game blueprint was dependent on math and utility libraries, then each of those required each other and some blueprints from game. It was total mess, at some point when i edited single function in one of libraries other lib (And every single blueprint that used any function from that library) got “uncompiled” status. But compiling one library made other “uncompiled”. Yup i was forced to create new empty project and recreate everything there. It was some time ago, since then Epic fixed a lot of bugs, but when you push blueprints too far you may get something like that.