# Flow Interaction

Level: Intermediate

## Goal

Use Flow Interaction to let a character find nearby targets, focus one target, show target feedback, and run interaction logic through Flow graphs.

## What It Is

Flow Interaction is the owner-target interaction layer. A `Flow Interaction Owner` scans and selects. A `Flow Interaction Target` defines where interaction happens, whether it can be used, how important it is, and what visual feedback appears while focused.

It is not a quest system, inventory system, dialogue system, or input binding system. It detects and routes interaction intent. The graph decides the gameplay result.

## Setup

Use the GameObject menu:

* `GameObject/Flow Core/Flow Interaction Target` creates a target prefab.
* `GameObject/Flow Core/Flow Player` already provides a player-facing character setup that can use interaction behavior.

Use Flow Graphs for behavior:

* Owner instructions ask the current target to interact, set an explicit target, clear focus, change scan mode, or read candidate data.
* Target instructions show or hide target canvas feedback, change target properties, or ask a target to interact through an owner.
* Event conditions read the current Flow Interaction event context during Focus, Blur, and Interact chains.

## Owner And Target Model

The Owner is the actor. It has a scan radius, a selection mode, a current target, an optional explicit target, and events for Focus, Blur, and Interact.

The Target is the interactable object. It has its own radius, priority, local interaction point offset, optional model root, optional Canvas, optional CanvasGroup, and events for Focus, Blur, and Interact.

The Owner does not choose every object in the scene. It collects registered targets whose target radius overlaps the owner radius. It then filters invalid candidates and selects one candidate according to mode.

## Focus, Blur, And Interact

Focus happens when the Owner changes from no target to a target, or from one target to another. The Owner emits an owner-side Focus event. The Target also receives a target-side Focus event.

Blur happens when the Owner stops focusing a previous target. The Owner emits an owner-side Blur event. The Target also receives a target-side Blur event.

Interact happens when interaction is requested and the current target is valid. The Owner emits an owner-side Interact event, then the Target receives a target-side Interact event.

```mermaid
flowchart LR
    A["Owner scans"] --> B["Collect candidates"]
    B --> C["Select target"]
    C --> D{"Target changed?"}
    D -->|Yes| E["Blur previous"]
    D -->|Yes| F["Focus next"]
    D -->|No| G["Keep current target"]
    F --> H["Interact requested"]
    G --> H
    H --> I{"Can interact now?"}
    I -->|Yes| J["Owner Interact event"]
    J --> K["Target Interact event"]
    I -->|No| L["No interaction"]
```

## Target Selection Modes

Nearest:

* Selects the closest valid target after priority is considered.
* Use it for simple collection, pickup, and examine interactions.

Forward:

* Requires the target to be inside the owner's forward angle.
* Use it when players should face the object they want.

Explicit:

* Uses a target assigned by graph logic.
* Use it for scripted moments, lock-on behavior, tutorial guidance, or UI-selected targets.

## Design Levers

Owner radius:

* Larger radius makes interaction easier to discover.
* Smaller radius requires closer positioning.

Target radius:

* Larger target radius makes large objects easier to focus.
* Smaller target radius makes precise objects less noisy.

Priority:

* Higher priority helps important targets win when several candidates are nearby.
* Overusing high priority can make nearby targets feel ignored.

Forward angle:

* Wider angle feels forgiving.
* Narrower angle rewards facing and camera alignment.

Canvas visibility:

* Auto Canvas Visibility makes focus feedback immediate.
* Manual canvas instructions are better when the graph owns UI timing.

## Practical Scenarios

Pickup item:

* Add a Flow Interaction Target to the item.
* Let the player Owner use Nearest or Forward mode.
* On Interact, run a graph that hides the item, adds inventory data, or plays a Gesture.

Workbench:

* Give the target a larger radius and visible canvas.
* Use Interact to open crafting UI.
* Use Target Can Interact to disable it while another process is active.

NPC conversation:

* Use Forward mode so the player must face the NPC.
* Show a world-space prompt on Focus.
* On Interact, run dialogue logic and optionally set the character busy.

Scripted object:

* Set an explicit target from a graph.
* Use Interact With Target when focus should not change.
* Clear the explicit target when the scripted moment ends.

## Development Tips

* Use Owner instructions for actor intent. Use Target instructions for object feedback.
* Keep Target priority rare and meaningful.
* Put the interaction point offset at the place the player expects to use, not necessarily at the object pivot.
* Use CanvasGroup feedback for focus prompts, and graph-owned UI for larger panels.
* Use event-side conditions when the same graph can run from owner-side or target-side events.
* Use Has Candidates and Candidate Count to debug why the player cannot focus anything.

## Common Mistakes

* Making every target high priority. This removes the value of priority.
* Using Nearest mode when the design expects facing. Forward mode gives clearer player intent.
* Forgetting that disabled Owners clear their runtime target.
* Expecting a Target to interact with itself. A target rejects its own owner GameObject by default.
* Assuming canvas feedback is gameplay state. Canvas visibility is feedback; graph logic should own gameplay consequences.
* Forgetting to turn off Can Interact during cutscenes, locked states, or unavailable objects.

## Related

* [Flow Character](/flow-core-docs/documentation/gameplay-modules/flow-character.md)
* [Character Interaction Catalog](/flow-core-docs/documentation/reference/character-interaction-catalog.md)
* [Character and Interaction Runtime](/flow-core-docs/documentation/runtime-guide/character-interaction-runtime.md)
* [Invoke and Reject Modes](/flow-core-docs/documentation/reference/invoke-and-reject-modes.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/gameplay-modules/flow-interaction.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.
