Skip to main content

Workflow: Creating and Using Actions

While a Query asks a stateless question about the world (Is this true?), an Action performs a complex, stateful process over time (Do this thing).

Actions are reusable, asynchronous Blueprint objects that encapsulate gameplay logic that isn't instantaneous. Think of them as "mini-state machines" for specific tasks.

  • Examples of Actions:
    • Reloading a weapon (lasts 3 seconds, can be interrupted).
    • Hacking a terminal (requires a series of steps or a timer).
    • Channeling a spell (stays active until a button is released or the player is hit).

Why Use an Action?

  1. Asynchronicity: Actions are latent. You fire an Activate pin, and the main Blueprint execution continues immediately via the Then pin. The Action will notify you later via its OnSuccess or OnFailure output pins when its job is done.
  2. Encapsulation: All the complex logic for a task (timers, listening for other events, multi-step checks) lives inside its own self-contained Blueprint, keeping your main Event Graph clean and readable.
  3. Reusability: You can create a generic Action like BPA_ApplyEffectOverTime and use it in dozens of different places without ever duplicating logic.
  4. Cancellation: Actions can be cancelled. If a player starts reloading but then decides to sprint, you can get a reference to the reloading Action and cancel it mid-process.

Actions are the ultimate tool for decoupling complex behavior from its trigger.


Step 1: Create the Action Blueprint

Let's create a simple Action that simulates a "hack" that takes 2 seconds to complete.

  1. In the Content Browser, right-click and select FactsDB.
  2. Search for Fact Action Async. Select it.
  3. Name the new Blueprint, for example, BPA_HackTerminal.

Creating the Action Blueprint

Step 2: Implement the Action Logic

Open BPA_HackTerminal. You will see that the Event Graph already contains two events: On Activate and On Cancel.

  • On Activate: This is fired when the Action's node is executed in another Blueprint. This is the entry point for your logic.
  • On Cancel: This is fired if the Action is cancelled externally. You should use this to clean up any timers or state.

Let's implement our 2-second hack:

  1. From the Event On Activate node, drag off the execution pin and add a Set Timer By Event node with a Time of 2.0 seconds.
  2. After the Timer completes, add a Trigger Success node. This is a special function available only inside Action Blueprints that fires the OnSuccess output pin on the main node.

If the hack could be interrupted or fail, you could add logic that calls Trigger Failure instead. For this example, our simple timer is enough. Compile and save the Blueprint.

Simple logic for the Activate event inside an Action Blueprint

Step 3: Use the Action in Blueprints

The system automatically discovers your new Action and creates a factory node for it in the Blueprint context menu.

Final look of the Hack Terminal Action node in the Blueprint context menu

  1. Open any Blueprint (like your Player Character).
  2. Right-click in the Event Graph and search for "Fact Action". You will see a new entry: Fact Action: Hack Terminal. Add this node to your graph.
  3. This node is asynchronous and has several execution pins:
    • Activate (Input): Run this execution pin to create and start the Action.
    • Cancel (Input): Run this pin to stop an active Action. You'll need to connect the Action Object output pin to this.
    • Then (Output): Fires immediately after the Action has been created and started.
    • On Success (Output): Fires only when the Action inside calls Trigger Success (in our case, after 2 seconds).
    • On Failure (Output): Fires only when the Action inside calls Trigger Failure.

Connect the On Success and On Failure pins to the logic you want to execute when the hack is complete.

Using the custom Hack Terminal Action node in a Blueprint graph

Cancelling Actions

The Action Object output pin provides a reference to the live Action instance. You can save this to a variable. If you need to stop the action early (e.g., the player moves away from the terminal), you can get the variable and connect it to the Action Object input on a separate Cancel call for the same node type.

That's it! You have successfully encapsulated a 2-second latent operation into a single, clean, and reusable node. If you now need to change the hack duration or add a skill check, you only need to modify the BPA_HackTerminal Blueprint; every location that uses it will be updated automatically.

This concludes the basic workflow guide. You now have the fundamental skills to define, manage, and use data with FactsDB. The following sections will dive deeper into the more advanced features and C++ architecture.

Next Up: Programmer's Guide: Runtime Architecture