Getting Started


This is the documentation for Arbor 3.2.4 and earlier.

See Arbor Documentation for the latest documentation.

Information “Arbor 3: FSM & BT Graph Editor”

  • I want to make games using finite state machines and behavior trees!
  • However, I want to code my behavior that depends on game logic!
  • A graph editing window of a finite state machine and a behavior tree that can be used at such time,
    It is a simple graph editor asset that allows you to write scripts according to the behavior you want to create.

What is finite state machine (FSM)?

  • The finite state machine, and behavior in a certain state, it is a mechanism for transition from the state to another.
  • For example, switches and lights.
    • The switch and the lamp there is a state of ON and OFF, will also be ON lamp if the ON switch.
    • Switch is switched to ON If you press, is the behavior to switch to OFF and press again.
    • Electric light will be the behavior to put the lights if ON.

For details, please refer to “State machine“.

What is a Behaviour Tree (BT)?

  • It is a tree structure of behaviors that makes it possible to handle the priority of action and the condition for doing actions as a set.
  • For example, consider enemy AI.
    • The behavior approaching the player is done if the distance to the player is short.
    • In other cases, it will cycle around a fixed route.
    • Behaviors approaching players can be said to have a higher priority than behaviors traveling on certain routes.

For details, see “Behaviour Tree“.

Get the Arbor

Preparation for using Arbor

Project creation

If you do not have a project that uses Arbor, you need to create a new project.

For details on how to create a project, see Getting started in the Unity Manual.

By choosing Arbor from the “Asset packages” button, you can skip importing work later.

If you can not find the Arbor package in the list, see “Importing Arbor” below.

Finally, press the “Create Project” button to create the project.

Arbor import

This task is necessary if you did not import the Arbor package in “Create Project” or if you want to import Arbor into an already existing project.

To import Arbor, first display the AssetStore window.

From the menu, select “Window > Asset Store” or press Ctrl + 9 on the shortcut.

When the AssetStore window is displayed, click the”My Downloads” button on the toolbar to switch to download list.

Click “My Purchased” and find the Arbor package from the list.

If “Download” button is displayed, click to start downloading.

Click on the “Import” button to display the Import Unity Package window.

Import is completed by clicking the Import button at the lower right of the window.

How to use

State Machine

ArborFSM is a component that controls the state machine.

You can combine in-game logic by adding ArborFSM to GameObject and setting nodes such as State in the ArborEditor window.

Behaviour Tree

Behaviour Tree is a component that controls the behavior tree.

You can combine in-game logic by adding BehaviourTree to GameObject and setting nodes such as ActionNode in the ArborEditor window.

Common usage of graph

The name change of node

  • Double click on the header part at the top of the inside of the node frame, select “Rename” from right click or setting icon.
    Enter in the displayed text box.
    GIF

Delete Node

  • Click to select nodes.
  • Right-click on an empty area and select “Delete”, or press the Delete key.
    GIF

Open the Behaviour manual

For built-in scripts and scripts with BehaviorHelp attribute, the help icon to open the manual is displayed.

  • Click the help icon next to the title bar of various behaviors

Script Reference : BehaviourHelp

Choose how to specify the value

  • If there is a field next to  mark of each property, you can choose how to specify the value by clicking.
    GIF
  • Unlike the choice depending on the type of value, it is as follows for the Lord.
    • Constant
      Specify a fixed value
    • Parameter
      Refer to the parameter.
      For details on parameters, see “About ParameterContainer” below.
    • Random
      Get at random from within the specified range.
    • Calculator
      It accepts the input from the operation node.
      For details about computation nodes, see “About calculator node” below.

Data flow

Arbor has a function to pass data between nodes.

You can also use calculator nodes to perform simple calculations.

For details, refer to the “Data flow” page.

Manual : Data flow

About Parameter container

ParameterContainer is a component used to share data between graphs.

For details, refer to the “ParameterContainer” page.

Manual : ParameterContainer

Coding

You can prepare the behavior and the processing of your own to create a script of C#, JavaScript,Boo.

Creating a script file

  • Right-click on the location you want to create from the Project window.
  • From the right-click menu, and select “Create> Arbor > State Behaviour C# Script”.
  • Determined to enter the file name

State Connection

  • Declare StateLink wearing a public or SerializeField attribute to the script that you have created.
    The declaration automatically become editable Arbor Editor if.

    using UnityEngine;
    using Arbor;
    
    public class TestBehaviour : StateBehaviour {
    	public StateLink nextState;
    	// Approximately
    }
    

  • It is referred to as the Transition in the transition you want to timing.
    Transition( nextState );
    

Input from the calculator node

  • Declare and InputSlotInt and InputSlotFloat wearing a public or SerializeField attribute to create scripts.
    (For InputSlot<T> generic class can not be serialized on the Unity of the specification, please use the class was always inherited)
    Automatically become editable Arbor Editor if the declaration.

    using UnityEngine;
    using Arbor;
    
    public class TestBehaviour : StateBehaviour
    {
    	public InputSlotInt slotInt;
    	// Approximately
    }
    

  • To get the value is to use the GetValue method.
    int data = 0;
    slotInt.GetValue(ref data);
    if (data == 10)
    {
    	Debug.Log("Test");
    }
    

Input from the calculator node(Flexible)

  • Declare and FlexibleInt and FlexibleFloat wearing a public or SerializeField attribute to create scripts.
    using UnityEngine;
    using Arbor;
    
    public class TestBehaviour : StateBehaviour
    {
    	public FlexibleInt flexible;
    	// Approximately
    }
    


    If you select Calculucator in ArborEditor window accepts an input from the computing node.

  • To get the value is to use the value property.
    if (flexible.value == 10)
    {
    	Debug.Log("Test");
    }
    

Output to the calculator node

  • Declare and OutputSlotInt and OutputSlotFloat wearing a public or SerializeField attribute to create scripts.
    (For OutputSlot<T> generic class is not serialized on the Unity of the specification, please use the class was always inherited)
    Automatically become editable Arbor Editor if the declaration.

    using UnityEngine;
    using Arbor;
    
    public class TestBehaviour : StateBehaviour
    {
    	public OutputSlotInt slotInt;
    	// Approximately
    }
    

  • To set the value to use the SetValue method.
    slotInt.SetValue(10);
    

Editor extension

  • Such as available inspector extension and PropertyDrawer is I can also be used to StateBehaviour in Unity

Important point

  • For enabled of MonoBehaviour are used internally already for execution control, please use the behaviourEnabled to be a substitute.

To the next step