Fab Store

Gate

A standard Unreal Engine flow-control macro that acts as a controllable valve for execution flow. When the gate is open, execution pulses pass through; when closed, they are blocked. The gate can be opened, closed, or toggled at any time.

Category: Flow Control Level: Beginner C++ / Macro: StandardMacros::Gate

YouTube Video Lesson (#06)

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
Enter Input Exec (White) - The main execution input. If the gate is open, the pulse passes to Exit. If closed, it is blocked.
Open Input Exec (White) - Sets the gate state to Open. Does not trigger Exit — only changes internal state.
Close Input Exec (White) - Sets the gate state to Closed. Does not trigger Exit — only changes internal state.
Toggle Input Exec (White) - Flips the gate to the opposite state (Open↔Closed). Does not trigger Exit.
Start Closed Input Boolean (Red) True When True, the gate starts closed (default). Set to False to start open.
Exit Output Exec (White) - Fires when Enter is triggered while the gate is Open.

Key Concepts

  • The gate remembers its state (open or closed) as long as the Actor instance exists.
  • The Open, Close, and Toggle pins only change the internal state; they do not pass execution pulses through to Exit.
  • The gate does not auto-reset on its own; it requires explicit signals to open or close.
  • Extremely useful for continuous actions that need to be explicitly started and stopped.

Practical Use Cases

1. Keyboard-Controlled Flow Gate (Lesson Example)

To listen to keyboard input within an Actor, set up Event BeginPlay → Enable Input (Get Player Controller 0):

  • E Key (Enter): Logs "Girildi." and pulses the Enter pin. If the gate is open, flow exits through Exit and logs "Geçiş gerçekleştir."; if closed, flow is blocked.
  • O Key (Open): Logs "Açıldı." and opens the gate.
  • C Key (Close): Logs "Kapatıldı." and closes the gate.
  • T Key (Toggle): Logs "Değiştirildi." and toggles gate state between open and closed.

2. Button Hold Continuous Action

Connect a button's Pressed pin to Open, Released to Close, and an Event Tick to Enter. The logic connected to the Exit pin will run every frame, but only while the button is actively held down.

3. Phase-Based Game Logic

Open the gate when a specific phase starts (like a boss fight), and close it when the phase ends (the boss is defeated). Recurring logic connected to the Enter pin will only pass through during the fight phase.

Common Pitfalls & Gotchas

  • Forgetting "Start Closed" is true by default: Your gate won't pass execution from the start until you explicitly Open it unless you uncheck this property.
  • Misunderstanding state-changing pins: Connecting logic to Open/Close/Toggle pins expecting them to also trigger the Exit pin. They only change the state; execution must hit Enter to pass to Exit.
  • Persistence across object reuse: If an actor is pooled or reused instead of destroyed, the gate keeps its last state. You may need to manually reset the state.
ESC