[BUG] What happened to the Blueprint Function Library 4.3.0

Hello! What happened to the functions and why it was removed variables?

Error The variable “name” cannot be declared in FunctionLibrary “name”
**My project involved over 430 functions and about 6000 variables… ;(

My problem is slightly different. I just made a custom library, but no variables. In my blueprints if I use a function from my library everything works, until I close and reopen the blueprint using the function. At that point, the blueprint won’t compile anymore until I delete the library function and re-add it. No changes being made, the blueprint(s) just refuse to compile or save until the library function has been replaced (even with the same library function).


Thank you for your report. We were not able to investigate this on the engine version you reported, but there have been many version changes to UE4 since this question was first posted. With a new version of the Engine comes new fixes and it is possible that this issue has changed or may no longer occur. Due to timetable of when this issue was first posted, we are marking this post as resolved for tracking purposes.

If you are still experiencing the issue you reported in the current engine version, then please respond to this message with additional information and we will investigate as soon as possible. If you are experiencing a similar, but different issue at this time, please submit a new report for it.

Thank you.

Hello! Problems with variables was not available in version 4.2.
It would not be scary, but before variables were created the possibility of version 4.2 In later versions of all libraries now not working… screenshot attached.

In later versions it was impossible to create variables…

Hi xangs,

Thank you for your feedback. I have used the information and images you’ve provided to generate Jira Report [UE-5251]. Should this issue be addressed in a future release an update will be posted to this thread. In the meantime, try using this set up as a workaround:

I have been, unfortunately, if you create a function, then use the data variable it impossible to relate only to the originally created functions.
Because it is impossible to use for some reason the dynamic handling and writing of data to the contents of the actor. Used functions, but was very surprised that updates and they stopped working. :wink:

I have added this information and included the additional pictures to the bug report to better illustrate the significance of this issue. As I mentioned before, should this be addressed an update will be added to this thread.

Thanks again for your input.

Thank you!

I got the same problem? How to store shared variables in a function library?

still does…;( promised to fix it.

Hi Xangs,

While I had reported this as a bug it turns out this is a deliberate fix as the developer explained, “Function libraries can’t track state, so the only variables allowed are local variables. The fact they used to be allowed was an oversight, and dangerous.”

That sounds - strange.

If shared variables, accessible to a bunch of functions in their own namespace would be “dangerous” I wonder how simple static classes were working all these years. :wink:

So what solution are we supposed to use then to pack together functionality in a module-like structure? Pack every feature in an Actor-derived Blueprint and instantiate it in the world at 0,0,0?! (That’s in fact the only solution which works for me right now and it’s simply horrible to maintain).

;)) Says is true. Very suspicious, simply remove the ability to create a variable in the function. This is why working in version 4.2.1.

Hi guys,

As Steve mentioned, this functionality is intended, and it was implemented incorrectly when function libraries were first introduced. I can understand how it might be frustrating to be using the function library a certain way and then find out that wasn’t the correct way to be using it, and I’d like to help explain why and help you figure out how to achieve what you need in your project.

A Blueprint Function Library allows you to create functions that can be accessed anywhere. As such, these functions must be self-contained, otherwise the same function in multiple places accessing public variable can cause all sorts of problems, the least of which is overwriting of these variables in places you wouldn’t expect, and the worst of which can cause project crashes. In this respect, a function from the function library is much like a Macro, and the Blueprint Function Library is just the container for these functions. The functions within the library do not interact with each other, and are entirely independent of each other.

You can still use Local variables, however, and achieve much of the same effect. If you create an input and an output for your function, the local variables allow you to store the information you need while inside the function and output whatever you need.

If you have a use case that does not work with what I described above, let me know and we can try to figure out how to do it either inside the function or using some other method in Blueprints. Remember that the function library simply stores your collection of functions, each of which are self-contained and do not share variables explicitly, though you can pass variables in and out.

Hope that helps!

Hi Ben, and thanks for your explanation.
I see your point, but that doesn’t really solve my problem. When sharded variables are forbidden now in function libraries, what structure should I use to cluster blueprint functions which HAVE TO access the same variables and which are NOT independent? How to simulate something like a static class or a singleton?

Should I use an actor and spawn it in every scene at some random location with a getter-method called from outside which would give back the already spawned instance if present?

Are they any code-only-blueprints in UE4 which I could use instead of function libaries to implement just ‘stuff’ which can be called from outside?

I currently use function libs to extend the abilities of my character while using one file per skill (can’t pack anything in the same file because that doesn’t play well with GIT and there are many other people involved which would now edit the same blueprint over and over again).

If you absolutely need to share a variable between functions, that’s exactly what you’d use an Actor Blueprint for. Using a standard getter method and casting to this functions BP would the way to do it, as you suggested.

Can you show me some images of an example of a situation where you would need a shared variable for these functions? I would like to make sure we’re not missing a workaround that would allow you to use a function library.