> For the complete documentation index, see [llms.txt](https://docs.engagevr.io/developer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.engagevr.io/developer/afx/afx-graphs/using-afx-events.md).

# Using AFX Events

You can trigger an AFX event in a graph, which then causes any associated listeners to activate. This can include the the activation of flows in other graphs. To use AFX events, you require the following three components:

* An AFX Event asset.
* An `AFX Invoke AFXEvent` node in an AFX graph that will trigger the event.
* Something to listen for the invoked event. You can use an `On AFXEvent Invoked` node or an `AFXEvent Component`. An invoked event can trigger multiple listeners.

## Creating an AFX Event asset

1. In the **Project** panel, right-click in a folder, and then select **Create** > **AFX Event**.
2. Enter a name for the AFX asset.

## Invoking an AFX Event

1. Add an `AFX Invoke AFXEvent` node in an AFX graph.
2. Choose one of the following options:
   * Drag the AFX event asset that you want to invoke onto the **Afx Event** field.
   * Select the circle icon in the **Afx Event** field to open the Object Picker window, and then select the AFX event asset that you want to invoke.

<figure><img src="https://2640392766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5yxYHsXtlAaoMUrDWhLm%2Fuploads%2Fgit-blob-42b324e2c5f207cc4106ed81a04acdb0d62d56f9%2Fafx_event_invoke.png?alt=media" alt=""><figcaption><p>Dragging an AFX event asset onto an AFX Invoke AFXEvent node</p></figcaption></figure>

3. Connect a flow to the **Enter** port of the `AFX Event Invoke` node. When the flow is activated, the event will be invoked.

## Responding to an invoked event in an AFX graph

To respond to an invoked event in an AFX graph, use an `On AFX Event Invoked` node. When the event is invoked, the node will initiate a flow.

1. Add an `On AFXEvent Invoked` node in the AFX graph where you want to respond to the event.
2. Choose one of the following options:
   * Drag the AFX event asset to which you want to respond onto the **Afx Event** field.
   * Select the circle icon in the **Afx Event** field to open the Object Picker window, and then select the AFX event asset to which you want to respond.

<figure><img src="https://2640392766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5yxYHsXtlAaoMUrDWhLm%2Fuploads%2Fgit-blob-e32b2ac5c34337b446b39fc9e05b4d2a3e55e8d8%2Fafx_invoked_event.png?alt=media" alt=""><figcaption><p>Dragging an AFX event asset onto an On AFXEvent Invoked node</p></figcaption></figure>

3. Connect the **Exit** port from the `On AFX Event Invoked` node to the nodes that you want to activate.

## Responding to an invoked event in an AFXEvent Component

You can use an AFXEvent Component to trigger a list of function calls. To use an AFXEvent Component, complete the following steps:

1. **Optional**: Create an empty game object.
2. Add an `AFXEvent Component` component to your chosen game object.
3. Choose one of the following options:
   * Drag the AFX event asset to which you want to respond onto the **Afx Event** field.
   * Select the circle icon in the **Afx Event** field to open the Object Picker window, and then select the AFX event asset to which you want to respond.

<figure><img src="https://2640392766-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5yxYHsXtlAaoMUrDWhLm%2Fuploads%2Fgit-blob-1047d3a94c5f2384c33f86ee65438bc91af929e7%2Fafx_event_component.png?alt=media" alt=""><figcaption><p>Dragging an AFX event asset onto an On AFX Event component</p></figcaption></figure>

4. In the **On Event Triggered** list, select the plus symbol. A row for a triggered event appears.
5. Drag a game object that you want to modify in response to the event onto the object field.
6. From the function list, select the function that you want to call in response to the event.
7. Repeat from step 4 as needed.
