BlueprintPseudocode guide

Functions and events

Each function, event and macro starts with a header line. Its body is indented below it, in the order the white execution wires run.

Function

Inputs and outputs go in the header, followed by specifiers such as Pure, Const, Private and Category. Local variables come right under the header. A Return Node becomes return with its values named.

function ApplyDamage(float Amount) -> (float NewHealth)  [Category="Combat"]
    local int Hits = 0
    Health = Health - Amount
    return NewHealth=Health

Events

Engine and custom events become event with their output pins as parameters, and replication settings in brackets. Other nodes that start execution, such as input actions, start with on and have one block per output ([Pressed], [Released]).

An input event lists the settings of its Details panel that differ from the defaults: on F(Key Key) [ConsumeInput=false].

event BeginPlay()
    PlayIntro()

event ServerFire(float Spread)  [Server, Reliable]
    FireWeapon(Spread)

What a call does beyond the call

Some statements read like a plain call or assignment and do more. A comment says what:

  • // interface message: the call goes to whatever object it is given. If that object does not implement the interface, or is None, nothing happens and the outputs are their defaults.
  • // Server, Reliable and the other replication flags: the call runs on another machine, later; an Unreliable one may not run at all.
  • // calls OnRep_Health: setting a variable with a RepNotify function calls that function at once, on the machine that set it.
  • // broadcasts a FieldNotify change (UE5): the Set tells the variable's listeners, such as MVVM bindings, that it changed.
Target.Interact()  // interface message
ServerFire(0.5)  // Server, Reliable
Health = 5  // calls OnRep_Health
Ammo = 30  // broadcasts a FieldNotify change

An override that skips its parent

An overriding event or function does not run the parent's version unless a Call to Parent node does. When no Call to Parent is reachable and the parent has a version to skip, the header says so. The parent has one when a parent Blueprint implements it, or when C++ declares it a BlueprintNativeEvent.

event OnEnemyKilled(Pawn* Enemy)  // does not call the parent's OnEnemyKilled
    Score = Score + 1

Using a node's result

When other nodes read the outputs of a node with execution pins, its line declares them. A node with one output is Type Name =, named after its pin, or after the node when the pin is Return Value: bool Healed = MyLibrary::Heal(Target=Ally, Amount=10.0). A node with several outputs is var Name =, and each read is Name.Pin. A name that repeats in a graph gets _2, _3.

Calls on another object start with that object, Enemy.TakeHit(10.0). A call with one argument leaves out its name. Advanced pins (under the arrow at the bottom of a node) appear only when they are wired or changed.

event OnFire()
    var LineTraceByChannel = KismetSystemLibrary::LineTraceByChannel(Start=TraceStart, End=TraceEnd)

    if (LineTraceByChannel.ReturnValue)
        SpawnImpact(GameplayStatics::BreakHitResult(LineTraceByChannel.OutHit).Location)
One output
    bool Healed = MyLibrary::Heal(Target=Ally, Amount=10.0)

    if (Healed)
        PlayHealEffect()

A read the flow did not set

A wire can read a node's output from a place where that node has not run: in another event, on the other arm of a Branch, after a loop. It gets whatever an earlier run left there, or the default. Such a read is marked with the reason: /* breaks execution flow - assigned in 'Test2' event */, never assigned, not assigned on this path.

Nodes that two events both run are written once, under the event that comes first in the text, and the other event ends in a goto to them (see labels).

TestFunc(GetScale /* breaks execution flow - assigned in 'Test2' event */)

Delegates

The red delegate pin of an event, wired into a Bind node, is written as the event's name. A Create Event node becomes CreateEvent(FunctionName).

event BeginPlay()
    Enemy.BindEventToOnDeath(OnEnemyDied)

event OnEnemyDied()
    AddScore(100)
Create Event node
KismetSystemLibrary::SetTimerByEvent(Event=CreateEvent(HandleTimeout), Time=2.0, Looping=false)

Other graph kinds

Event dispatchers are listed as dispatcher OnDeath(Actor* Killer). A dispatcher or macro in a category says so as a function does, [Category="Combat"]. Macros start with macro and collapsed graphs with collapsed graph; their header lists every pin, execution pins as exec Name, inputs first, then outputs after ->: macro LoopTwice(exec Exec) -> (exec LoopBody, exec Completed, int Index). A collapsed graph follows the graph it sits in, after a // collapsed inside EventGraph: line. An Interface Blueprint's functions are declarations, so only their header is written: interface function GetScore() -> (int Score).

Anim graphs and state machines are skipped with a one-line note; an Anim Blueprint's event graph is written as usual. A Widget Blueprint's layout isn't written, only its graphs and view bindings. Level Blueprints, inside .umap files, aren't supported yet.

Renamed C++: redirect

The text prints names as the asset saved them. When the engine or project config renames one at load, the function or event that uses it starts with a redirect line: the saved name, then the new one. The asset takes the new name the next time it is saved.

function OnHit(Actor* Other)
    redirect function MyLibrary.Heal = MyLibrary.RestoreHealth
    redirect type EnemyBase = EnemyCharacter
    EnemyBase* AsEnemyBase = CastToEnemyBase(Other)  // nothing on: Cast Failed
    MyLibrary::Heal(Target=AsEnemyBase, Amount=10.0)