Functions, events & delegates
TPScript gives you fine-grained control over how functions surface to Blueprint. The same syntax applies in both high-level and low-level styles (the keyword sets differ slightly).
Calling functions
Function names are snake_case and are called like normal methods:
heal(25.0);
if (IsDead()) {
OnLevelUp();
}
C++ statements inside function bodies pass through verbatim, so you can call anything.
The five function flavors
| TPScript | C++ | Use case |
|---|---|---|
run_from_blueprint foo() | UFUNCTION(BlueprintCallable) | Blueprint calls your C++ logic |
blueprint_event foo() | UFUNCTION(BlueprintImplementableEvent) | Blueprint implements the body (no C++ body) |
event foo() | UFUNCTION(BlueprintNativeEvent) | C++ default body + Blueprint may override |
run foo() | plain method | internal C++ helper, not BP-exposed |
func (low-level) | UFUNCTION | full specifier control |
Low-level func with specifiers
func public void Heal(float Amount) BlueprintCallable category="Example"
{
if (Amount <= 0.0f) { return; }
StartingHealth += Amount;
}
BlueprintImplementableEvent - no body allowed
func public void OnLevelUp() BlueprintImplementableEvent category="Example"
A BlueprintImplementableEvent (or high-level blueprint_event) cannot have a C++ body - the parser raises an error suggesting event/run_function if you need logic. But you can still call it (it dispatches to whatever Blueprint graph assigned to it).
BlueprintNativeEvent - C++ default + BP override
event on_damage(amount: number) {
// default implementation goes here; Blueprint can override via "_Implementation"
}
High-level event moves the body into the _Implementation function, letting Blueprint override it while keeping a C++ default.
func specifiers
Blueprint-facing: BlueprintCallable, BlueprintImplementableEvent, BlueprintPure, BlueprintNativeEvent, BlueprintEvent, BlueprintOverride, BlueprintAuthorityOnly, BlueprintCosmetic, BlueprintGetter, BlueprintSetter.
Networking: Server, Client, NetMulticast, Reliable, Unreliable, WithValidation.
Other: CallInEditor, Exec, SealedEvent, BlueprintReadOnly.
Function extras: category="...", display_name="...", meta(...).
C++ method specifiers
virtual, override, static, const, inline, final, and pure (→ = 0 for interface methods).
method public bool IsDead() const {
return StartingHealth <= 0.0f;
}
method public virtual float GetSpeed() const override {
return Super::GetSpeed();
}
Parameters
Either name: type (high-level style) or type name (low-level/explicit) - both accepted:
// name:type
func public void ApplyDamage(amount: number, source: actor)
// type name
func public void ApplyDamage(float Amount, AActor* Source)
Defaults use =:
func public void Heal(float Amount = 10.0f)
Lifecycle overrides
These are pure TPScript conveniences that generate the correct UE overrides:
when_begin {
// -> void BeginPlay() override { ...; Super::BeginPlay(); }
}
when_tick dt {
// -> void Tick(float DeltaSeconds) override { ... }
// `dt` (if you name it) is renamed to DeltaSeconds automatically
}
when_end {
// -> void EndPlay(const EEndPlayReason::Type) override
}
Delegates
Declaring a delegate type
declare DynamicMulticast FExampleDoorOpened (OneParam APawn*, Opener)
Base kinds: DynamicMulticast, Dynamic, Multicast → map to DECLARE_DYNAMIC_MULTICAST_DELEGATE, DECLARE_DYNAMIC_DELEGATE, DECLARE_MULTICAST_DELEGATE. The default (no base) is DECLARE_DELEGATE.
Param kinds: ZeroParam, OneParam, TwoParams, ThreeParams, FourParams (emitting _OneParam, _TwoParams, etc.).
Using a delegate
A declare alone only creates the type - you need a field of that type to broadcast it:
uclass AExampleDoor : AActor meta: api=EXAMPLES_API
{
declare DynamicMulticast FExampleDoorOpened (OneParam APawn*, Opener)
field public FExampleDoorOpened OnDoorOpened
}
Broadcast from your code:
OnDoorOpened.Broadcast(GetInstigator());
Blueprints can bind to a multicast delegate if it's exposed as a BlueprintAssignable prop:
prop public FExampleDoorOpened OnDoorOpened BlueprintAssignable
Where declare lands
- File-scope
declares land in a shared<file>_Decl.h. - A delegate used as a
BlueprintAssignableUPROPERTYmember is inlined into the owning header (and excluded from_Decl.h) so UHT doesn't materialize a duplicate delegate function (avoidsC2011redefinition).
Next: Components.