# How to use State Machine

# Adding ArborFSM component

The ArborFSM component is required to use the state machine.

There are the following methods for adding ArborFSM components.

## Create button in Hierarchy window

- Click the Create button in the Hierarchy window or right click in the window
- Select “Arbor / ArborFSM”
- A GameObject with ArborFSM is created.

## ArborEditor window toolbar

- Open the ArborEditor window and click the “Create” button on the toolbar
- Select ArborFSM
- A GameObject with ArborFSM is created.

## Unselected menu of ArborEditor window

- Open the ArborEditor window and click the “Create ArborFSM” button in the menu displayed when graph is not selected
- A GameObject with ArborFSM is created.

## Inspector window “Add Component” button

- Select the GameObject you want to add ArborFSM in the Hierarchy window
- Click the “Add Component” button in the Inspector window
- Select “Arbor / ArborFSM”.
- ArborFSM is added to GameObject.

# Open ArborFSM graph in Arbor Editor window

To edit ArborFSM you need to open the ArborFSM graph in the Arbor Editor window.

- In the Hierarchy window, select GameObject with ArborFSM component.
- Click “Open Editor” button of ArborFSM component editor in Inspector window.

Also, if the Arbor Editor window has already been opened, it will switch if you select GameObjet with ArborFSM component in the Hierarchy window.

# Create State

- Right-click the position of the graph where you want to create a state.
- Select “Create State” in the menu.
- Input the name of the state and decide with the Enter key.

# Create Resident State

- Right-click the position of the graph where you want to create a resident state.
- Select “Create Resident State” in the menu.
- Input the name of the state and decide with the Enter key.

# Delete State

- Select the node you want to delete
- Select “Delete” from the right-click menu in the graph, or press the Delete key

# Set to start state

- Click the gear icon or right click in the node header section.
- Select “Set Start State”.

# Add Behaviour

You need to add a StateBehaviour in order for the state to work.

- Click the gear icon or right click in the node header section.
- Select “Add Behaviour”
- Select the StateBehaviour you want to add from the StateBehaviour selection menu.

# Insert Behaviour

To insert StateBehaviour in an arbitrary position, add it from the “Insert Behaviour” button.

- Mouse over near the center of the separator between behaviors in the state.
- Click the displayed “Insert Behaviour” button.
- Select “Add Behaviour”
- Select the StateBehaviour you want to add from the StateBehaviour selection menu.

# Drag Behaviour

## Move

By dragging and dropping StateBehaviour, you can switch the order of behavior and move to another node.

- Drag the title bar of behaviour
- Drop to the other node on the same node or to another node

## Copy

Hold Ctrl (Win) / Option (Mac) while dragging and dropping it to copy.

- Drag the title bar of behaviour
- Hold Ctrl (Win) / Option (Mac) and drop it to another position on the same node or to another node

# Delete Behaviour

- Click the gear icon or right click in the title bar.
- Select “Delete” from the menu

# Connect State

## Connect to existing node

- Drag the StateLink field in StateBehaviour
- Drop to the connected state

## Connect And Create a new state

- Drag the StateLink field in StateBehaviour
- Drop at the position in the graph where you want to create the state
- Select “Create State” in the menu.
- Input the name of the state and decide with the Enter key.

# Disconnect State

- Right-click on the connection line you want to disconnect
- Select “Disconnect” from the menu

# StateLink settings

Click on the StateLink gear icon to display the setting window.

Item | Contens
--- | ---
Name | Name of StateLink. When inputting, the display name of the StateLink field is changed.
Transition Timing | Setting of transition timing.
Line Color | Connection line color

## TransitionTiming

Item | Contens
--- | ---
Late Update Overwrite | Reserve to transition when LateUpdate. If the transition is already reserved in the same frame, overwrite it.
Immediate | Transit instantaneously at transition call. If the transition is looping, there is a possibility of infinite looping, so use with caution.
Late Update Dont Overwrite | Reserve to transition when LateUpdate. (Default) If the transition is already reserved within the same frame, do not overwrite it.

# Reroute Node

You can use the reroute node to bundle the state connection lines and change the direction.

## Connect

### Connect And Create a new Reroute node

- Drag the StateLink field in StateBehaviour
- Drop at the position in the graph where you want to create the state
- Select “Reroute” in the menu.

### Insert

- Right-click the position where you want to create a reroute node on the connection line.
- Select “Reroute” in the menu.

## Change direction

- Select reroute node to change direction
- Drag the direction icon to change it.

## Delete while keeping connection

- Right click on the reroute node
- Select “Delete (Keep Connection)”.