Unreal Blueprints (Visual Scripting)
Structure gameplay logic in Unreal Engine 5 Blueprints: pick the right graph, expose data
cleanly, and choose a communication method that doesn't create hard-reference spaghetti.
Targets UE 5.8. (Blueprints are node graphs; the snippets below describe node flows.)
When to use
- Use when authoring a Blueprint Class, wiring the Event Graph (BeginPlay/Tick/overlap),
using the Construction Script, creating variables/functions/macros, or choosing how two
Blueprints communicate (Cast, Interface, or Event Dispatcher).
- Use when the project has
*.uproject and Blueprint *.uasset files, and the user works
visually rather than in C++.
When not to use: performance-critical systems, large data structures, or anything that
benefits from source control diffs and unit tests → unreal-cpp-gameplay. Player input
mapping → unreal-enhanced-input. AI logic → unreal-behavior-trees.
Core workflow
- Choose the Blueprint type. A Blueprint Class (derived from Actor/Pawn/Character/
ActorComponent) defines a reusable object. The Level Blueprint is a per-level graph for
level-specific scripting only — don't put reusable logic there.
- Use the Construction Script for editor-time setup (procedural placement, configuring
components from variables) — it runs when the actor is placed or edited, not during play.
- Use the Event Graph for runtime logic.
Event BeginPlay for init, input/overlap events
for reactions. Avoid Event Tick unless you truly need per-frame work.
- Expose data with variables; click the eye icon to make a variable Instance Editable, and
group related ones with categories. Mark pure functions (no exec pin) for getters.
- Pick a communication method by coupling (see Patterns): direct Cast for things you
own, Blueprint Interface to call across types without hard references, Event
Dispatcher to broadcast one-to-many.
- Verify with the Blueprint debugger: drop breakpoints on nodes, watch variable values,
and use Print String to confirm execution paths during Play In Editor (PIE).
Patterns
1. Reactive Event Graph (no Tick)
Event BeginPlay
-> Set 'StartLocation' = GetActorLocation
-> Bind Event to OnComponentBeginOverlap (TriggerVolume) [calls custom event OnEnterZone]
OnEnterZone (Other Actor)
-> Branch: Other Actor == Player?
True -> Open Door (Timeline drives the rotation) // event-driven, runs once
Prefer events (overlaps, timers, dispatchers) and Timelines over polling in Tick.
2. Direct reference + Cast (tight coupling, use sparingly)
Overlapped Actor (Actor ref)
-> Cast To BP_Player
Cast Failed -> (do nothing)
Success -> call BP_Player.ApplyDamage(10)
Cast To creates a hard reference to that class (it loads with this Blueprint). Fine when the
caller genuinely depends on that type; otherwise prefer an Interface.
3. Blueprint Interface (decoupled call)
// 1. Create BPI_Interactable with function 'Interact(Instigator)'.
// 2. Add the interface to BP_Door, BP_Chest, BP_Lever and implement 'Interact' in each.
// 3. Caller, with any Actor ref:
Player presses Use
-> Does Object Implement Interface (BPI_Interactable)? // safe check, no Cast/hard ref
True -> Interact (Message) on Target Actor
4. Event Dispatcher (one-to-many broadcast)
// In BP_Player: declare Event Dispatcher 'OnHealthChanged (float NewHealth)'.
TakeDamage -> Set Health -> Call 'OnHealthChanged' (Health) // broadcast
// In WBP_HUD BeginPlay: Bind Event to 'OnHealthChanged' -> update health bar.
// Many listeners can bind; the player never references them.
Pitfalls
- Cast spaghetti / long load times — chains of
Cast To create hard references that pull
whole asset trees into memory. Decouple with Interfaces or Dispatchers.
- Logic in the Level Blueprint that should be reusable — it can't be reused across levels.
Put it in a Blueprint Class.
Event Tick overuse — every-frame nodes add up fast. Use events, Timers
(Set Timer by Event), and Timelines instead.
- Construction Script doing gameplay — it runs in the editor on edit/placement; spawning
gameplay actors or starting logic there causes editor-only artifacts. Init in BeginPlay.
- Variable not visible on the instance — toggle Instance Editable (the eye); to edit before
spawn via Spawn node, also mark "Expose on Spawn".
- Interface call did nothing — the target doesn't implement the interface; use "Does
Implement Interface" before calling, or use the Message version which is safe on non-implementers.
References
- For a decision guide on Cast vs Interface vs Event Dispatcher and step-by-step dispatcher
binding, read
references/communication.md.
- Primary docs: "Blueprints Visual Scripting"
(
https://dev.epicgames.com/documentation/en-us/unreal-engine/overview-of-blueprints-visual-scripting-in-unreal-engine).
Related skills
unreal-cpp-gameplay — when to drop to C++; how BP and C++ classes interoperate.
unreal-enhanced-input — the modern way to feed input events into these graphs.
unreal-behavior-trees — AI decision logic that Blueprints trigger.
1---2name: unreal-blueprints3description: Build Unreal Engine 5 gameplay with Blueprint visual scripting: Blueprint Classes, the Event Graph and Construction Script, variables/functions/macros, and Blueprint communication (Cast, Interfaces, Event Dispatchers). Use when working in Blueprints, wiring an event graph, deciding how Blueprints talk to each other, or when the user mentions Blueprint, BP, event graph, construction script, or a Blueprint .uasset.4---5
6# Unreal Blueprints (Visual Scripting)
7
8Structure gameplay logic in Unreal Engine 5 Blueprints: pick the right graph, expose data
9cleanly, and choose a communication method that doesn't create hard-reference spaghetti.
10Targets **UE 5.8**. (Blueprints are node graphs; the snippets below describe node flows.)
11
12## When to use
13
14- Use when authoring a Blueprint Class, wiring the Event Graph (BeginPlay/Tick/overlap),
15 using the Construction Script, creating variables/functions/macros, or choosing how two
16 Blueprints communicate (Cast, Interface, or Event Dispatcher).
17- Use when the project has `*.uproject` and Blueprint `*.uasset` files, and the user works
18 visually rather than in C++.
19
20**When *not* to use:** performance-critical systems, large data structures, or anything that
21benefits from source control diffs and unit tests → `unreal-cpp-gameplay`. Player input
22mapping → `unreal-enhanced-input`. AI logic → `unreal-behavior-trees`.
23
24## Core workflow
25
261. **Choose the Blueprint type.** A **Blueprint Class** (derived from Actor/Pawn/Character/
27 ActorComponent) defines a reusable object. The **Level Blueprint** is a per-level graph for
28 level-specific scripting only — don't put reusable logic there.
292. **Use the Construction Script for editor-time setup** (procedural placement, configuring
30 components from variables) — it runs when the actor is placed or edited, *not* during play.
313. **Use the Event Graph for runtime logic.** `Event BeginPlay` for init, input/overlap events
32 for reactions. Avoid `Event Tick` unless you truly need per-frame work.
334. **Expose data with variables**; click the eye icon to make a variable Instance Editable, and
34 group related ones with categories. Mark **pure** functions (no exec pin) for getters.
355. **Pick a communication method by coupling** (see Patterns): direct **Cast** for things you
36 own, **Blueprint Interface** to call across types without hard references, **Event
37 Dispatcher** to broadcast one-to-many.
386. **Verify** with the Blueprint debugger: drop breakpoints on nodes, watch variable values,
39 and use Print String to confirm execution paths during Play In Editor (PIE).
40
41## Patterns
42
43### 1. Reactive Event Graph (no Tick)
44
45```text
46Event BeginPlay
47 -> Set 'StartLocation' = GetActorLocation
48 -> Bind Event to OnComponentBeginOverlap (TriggerVolume) [calls custom event OnEnterZone]
49
50OnEnterZone (Other Actor)
51 -> Branch: Other Actor == Player?
52 True -> Open Door (Timeline drives the rotation) // event-driven, runs once
53```
54
55Prefer events (overlaps, timers, dispatchers) and Timelines over polling in Tick.
56
57### 2. Direct reference + Cast (tight coupling, use sparingly)
58
59```text
60Overlapped Actor (Actor ref)
61 -> Cast To BP_Player
62 Cast Failed -> (do nothing)
63 Success -> call BP_Player.ApplyDamage(10)
64```
65
66`Cast To` creates a hard reference to that class (it loads with this Blueprint). Fine when the
67caller genuinely depends on that type; otherwise prefer an Interface.
68
69### 3. Blueprint Interface (decoupled call)
70
71```text
72// 1. Create BPI_Interactable with function 'Interact(Instigator)'.
73// 2. Add the interface to BP_Door, BP_Chest, BP_Lever and implement 'Interact' in each.
74// 3. Caller, with any Actor ref:
75Player presses Use
76 -> Does Object Implement Interface (BPI_Interactable)? // safe check, no Cast/hard ref
77 True -> Interact (Message) on Target Actor
78```
79
80### 4. Event Dispatcher (one-to-many broadcast)
81
82```text
83// In BP_Player: declare Event Dispatcher 'OnHealthChanged (float NewHealth)'.
84TakeDamage -> Set Health -> Call 'OnHealthChanged' (Health) // broadcast
85
86// In WBP_HUD BeginPlay: Bind Event to 'OnHealthChanged' -> update health bar.
87// Many listeners can bind; the player never references them.
88```
89
90## Pitfalls
91
92- **Cast spaghetti / long load times** — chains of `Cast To` create hard references that pull
93 whole asset trees into memory. Decouple with Interfaces or Dispatchers.
94- **Logic in the Level Blueprint that should be reusable** — it can't be reused across levels.
95 Put it in a Blueprint Class.
96- **`Event Tick` overuse** — every-frame nodes add up fast. Use events, Timers
97 (`Set Timer by Event`), and Timelines instead.
98- **Construction Script doing gameplay** — it runs in the editor on edit/placement; spawning
99 gameplay actors or starting logic there causes editor-only artifacts. Init in BeginPlay.
100- **Variable not visible on the instance** — toggle Instance Editable (the eye); to edit before
101 spawn via Spawn node, also mark "Expose on Spawn".
102- **Interface call did nothing** — the target doesn't implement the interface; use "Does
103 Implement Interface" before calling, or use the Message version which is safe on non-implementers.
104
105## References
106
107- For a decision guide on **Cast vs Interface vs Event Dispatcher** and step-by-step dispatcher
108 binding, read `references/communication.md`.
109- Primary docs: "Blueprints Visual Scripting"
110 (`https://dev.epicgames.com/documentation/en-us/unreal-engine/overview-of-blueprints-visual-scripting-in-unreal-engine`).
111
112## Related skills
113
114- `unreal-cpp-gameplay` — when to drop to C++; how BP and C++ classes interoperate.
115- `unreal-enhanced-input` — the modern way to feed input events into these graphs.
116- `unreal-behavior-trees` — AI decision logic that Blueprints trigger.