# Run a Flow Graph in a Scene

Level: Beginner

## Goal

Wire a Flow Graph into a scene object and let a Unity lifecycle Trigger start it at runtime.

This page reinforces the runtime binding behind the Hello Flow Core tutorial. The graph asset describes behavior. The scene object decides which graph instance runs, which Local Blackboards it can read, and when Unity lifecycle events can start chains.

## Prerequisites

* You completed [First 15 Minutes](/flow-core-docs/documentation/tutorials/first-15-minutes.md), or you have an equivalent Flow Graph asset.
* A scene GameObject has `FlowCoreProcess` and a Local `Blackboard`.
* The `Blackboard` contains a `String` key named `Say`.

## What You Will Build

You will confirm the scene binding that makes a visual graph run:

* `FlowCoreProcess` owns the graph asset for this scene object.
* `Local Blackboards[0]` points to the `Blackboard` that contains `Say`.
* A `Trigger` node listens for Unity `Start`.
* An `Action` node logs the Local Blackboard value.

The expected result is still the same beginner-friendly signal: the Unity Console prints the value stored in `Say`.

## Steps

1. Select the scene GameObject that should run the graph.

   This is the runtime owner. In the beginner setup, it is the `Hello Flow Core` GameObject.
2. Check the `FlowCoreProcess` component.

   Assign the Flow Graph asset if it is missing. Then find `Local Blackboards` and add the local `Blackboard` component.

   The graph asset lives in the project. The process lives in the scene. The process is what turns the asset into a running graph instance.
3. Check the `Blackboard` component.

   Confirm it has a `String` value, the key is `Say`, and the value is the text you want to log, such as `Hello Flow Core`.

   The Blackboard owns the data. The graph only says where to read the value from.
4. Open the graph in the Flow Graph editor.

   Set Debug Context to the same scene GameObject.

   Debug Context should match the runtime owner. If it points to a different object, editor previews may not reflect the Blackboard that will be used in Play Mode.
5. Check the runtime start point.

   Add or select a `Trigger` node. Set `Trigger Bus Type` to `Unity` and `Unity Event` to `Start`.

   This makes the graph event-driven from Unity lifecycle. No beginner C# call is required.
6. Check the visible work.

   Add or select an `Action` node. Connect `Trigger.Out` to `Action.In`.

   Add `Log String` from `Debug/Value/String` and configure it to read:

   * Source: `Blackboard`
   * Scope: `Local`
   * Blackboard index: `0`
   * Key: `Say`
7. Enter Play Mode.

   Watch the Console for the value stored in `Say`.

## Verify the Result

* The Unity Console prints the value stored in `Say`.
* Changing the Blackboard value changes the next Console output without changing the graph structure.
* The graph starts because the scene object reached Unity `Start`, not because a custom script called the graph.

## Common Mistakes

| Symptom                                                   | Likely cause                                                                                   | Fix                                                                          |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Nothing happens in Play Mode.                             | The graph asset is not assigned, the process is disabled, or the Trigger is not Unity `Start`. | Recheck `FlowCoreProcess`, component enabled state, and Trigger settings.    |
| The Console prints the wrong value.                       | The instruction reads from the wrong Blackboard scope, index, or key.                          | Use scope `Local`, index `0`, key `Say` for the beginner setup.              |
| The Console prints nothing but the graph looks connected. | The Blackboard is on the GameObject but not listed in `Local Blackboards`.                     | Add the Blackboard component to the process `Local Blackboards` list.        |
| Editor previews do not match Play Mode.                   | Debug Context points to a different GameObject.                                                | Set Debug Context to the GameObject that owns the running `FlowCoreProcess`. |
| The key cannot be found.                                  | Key spelling or value type does not match.                                                     | Use exact key `Say` and a `String` Blackboard value.                         |

## Troubleshooting Loop

When the scene graph does not behave as expected, check in this order:

1. Scene owner: the correct GameObject is selected and has `FlowCoreProcess`.
2. Graph binding: the correct Flow Graph asset is assigned.
3. Data binding: the Blackboard is present in `Local Blackboards`.
4. Runtime start: the Trigger uses Unity `Start`.
5. Flow connection: `Trigger.Out` is connected to `Action.In`.
6. Value path: `Log String` reads Local index `0`, key `Say`.
7. Observation: the Console is visible and not hiding the message.

## Next Steps

* To trigger graphs from gameplay code, use [Run Flow Core from Code](/flow-core-docs/documentation/getting-started/run-flow-core-from-code.md).
* To understand runtime order and data resolution, read [Lifecycle and Dataflow](/flow-core-docs/documentation/runtime-guide/lifecycle-and-dataflow.md).
* To debug graph behavior, use [Debug a Running Graph](/flow-core-docs/documentation/how-to-guides/debug-a-running-graph.md).
* To understand editor previews, read [Debug Context](/flow-core-docs/documentation/editor-guide/debug-context.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://flow-core.gitbook.io/flow-core-docs/documentation/tutorials/run-a-flow-graph-in-a-scene.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
