Do N
A standard Unreal Engine flow-control macro that limits execution to a set number of times (N). After being triggered N times, it blocks further execution until the Reset pin is fired.
YouTube Video Lesson (#05)
Interactive Blueprint Graph & Copyable Code
Use the "Copy Nodes" button in the graph below, then press Ctrl+V in an Unreal Engine 5 Blueprint Graph to paste the example:
Input and Output Pins
| Pin Name | Direction | Data Type | Default | Description |
|---|---|---|---|---|
| (Exec In) | Input | Exec (White) | - | Triggers the node. If the internal counter is less than N, fires Exit and increments the counter. |
| Reset | Input | Exec (White) | - | Resets the internal counter to zero, allowing the node to fire again up to N times. |
| N | Input | Integer (Cyan) | 1 | The maximum number of times the Exit pin will fire before the node stops executing. |
| Exit | Output | Exec (White) | - | Fires each time Enter is triggered while the counter is less than N. |
| Counter | Output | Integer (Cyan) | - | Outputs the current execution count (how many times the node has fired so far). |
Practical Use Cases
1. Trigger Volume with Limited Triggers (Video Example)
As demonstrated in the graph above, when the player character enters a Box Collision trigger (Get Player Pawn == Other Actor), the Do N node executes with N=2. The message "Emir, içeriye girdi." is printed only for the first two entrances. Once the limit is reached, execution is blocked until Reset is triggered.
2. Limited-Use Power-Up
Player can use a special ability only N times per round/life.
3. Progressive Difficulty
Spawn enemies N times, then stop spawning.
Common Pitfalls & Gotchas
- Forgetting to connect Reset: The node becomes permanently blocked after N uses.
- Setting N to 0: The Exit pin will never fire.
- Changing N dynamically after some executions: The counter doesn't reset when N changes.