Reference › Language
Function libraries
Blueprints of functions that any Blueprint can call.
- Page
- libraries
- Agent tool
- docs libraries
A function library is a Blueprint whose parent is BlueprintFunctionLibrary, Unreal’s own kind of
Blueprint for shared helpers. It holds only functions. They belong to the class, not to an object,
so they have no self, and any Blueprint calls them by the library’s name, with no object.
Calling a library’s functions
Section titled “Calling a library’s functions”Write the library, a dot and the function. The library is found by name like any class, so use
and the usual naming rules apply.
One program · 2 files, compiled together
blueprint BPL_Math : BlueprintFunctionLibrary at /Game/Lib/BPL_Math
// The value, kept between lo and hi.pure fn Clamp(x: int, lo: int, hi: int) -> int { if x < lo { return lo } if x > hi { return hi } return x}blueprint BP_Meter : Actor at /Game/Meter/BP_Meter
var Level: int = 0
fn Raise(by: int) { Level = BPL_Math.Clamp(Level + by, 0, 10)}Most library functions only compute a value, so they’re usually pure, with no exec pins, like the math nodes in Unreal’s own libraries.
A library has no variables of its own, so a ref parameter is how it changes one of the caller’s.
It works as in any function.
What a library can’t have
Section titled “What a library can’t have”Anything but functions is refused:
blueprint BPL_Math : BlueprintFunctionLibrary at /Game/Lib/BPL_Mathvar Count: int = 0…a function library has no variables…
dispatcher Changed(value: int)…a function library has no dispatchers…
on ReceiveBeginPlay {}…a function library has no events…
component Sound: AudioComponent…only an actor's Blueprint has components…
widget Title: TextBlock…only a widget Blueprint, whose parent is a UserWidget, has widgets…
implements MovieSceneEasingFunction…a function library implements no interfaces…
fn Owner() -> Object { return self}…a function library has no self…
A library’s parent is BlueprintFunctionLibrary, not another library. Unreal won’t make a child of
one, whether it’s a Blueprint’s or one of the engine’s own, such as KismetMathLibrary:
One program · 1 files, compiled together
blueprint BPL_Geometry : BPL_Math at /Game/Lib/BPL_Geometryerror: …a function library can't derive from another library, and BPL_Math is one…