# How to Trigger a Transition

To trigger a transition in a State Machine, call the Trigger method of the State Machine and pass the ID of the transition you want to trigger.&#x20;

Example: Imagine you have the following State Machine and want to trigger the transition with the ID Show Settings.

<figure><img src="/files/EteA94wntmtqhtdjpNAs" alt=""><figcaption></figcaption></figure>

The following two examples will show how you could achieve this with an UI Button in the inspector or from inside a script.

### UI Button OnClick Example

<figure><img src="/files/V6hJQSRcyDOHkNdUXwjA" alt=""><figcaption></figcaption></figure>

### Script Example&#x20;

This script will trigger the transition with name Show Settings on the State Machine set in the inspector when the “S” key is down.

```
using Ilumisoft.VisualStateMachine; 
using UnityEngine; 
public class TriggerExample : MonoBehaviour 
{ 
    //Reference to the state machine set via the inspector 
    [SerializeField] StateMachine stateMachine = null; 
    
    private void Update() 
    { 
        if(Input.GetKeyDown(KeyCode.S)) 
        { 
            stateMachine.Trigger("Show Settings"); 
        } 
    } 
}
```


---

# 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://ilumisoft.gitbook.io/visual-state-machine/get-started/how-to-trigger-a-transition.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.
