# ActionBehaviour

You can create an ActionBehaviour script and add the original action by describing what you want to do.

# Create an ActionBehaviour script file

- Right click at the place you want to create from the Project window.
- From the right-click menu, select “Create > Arbor > Behavior tree > ActionBehaviour C# Script”.
- Enter the file name and confirm

# Function to be called

If you add the ActionBehavior you created to the Behavior Tree graph, each function of the script will be called.

- OnAwake
  It is called the first time the action node becomes active.
- OnStart
  Called when the action node becomes active.
- OnExecute
  It is called when the action node is executed.
  For the execution timing, see UpdateSettings and ExecutionSettings in BehaviourTree.
  Arbor Reference : BehaviourTree
- OnAbort
  Called when the node is interrupted by the Decorator.
- OnEnd
  Called when the action node exits.

## Important point

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

# Call order

- You can also use the callback method of MonoBehaviour other than OnEnable and OnDisable, but please be aware that Start () will be called after OnExecute().

# Declaring variables

You can edit it in Arbor Editor by declaring a field with public or SerializedField attribute added to the created script.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using Arbor;
    using Arbor.BehaviourTree;

    [AddComponentMenu("")]
    public class TestActionBehaviour : ActionBehaviour
    {
    	public string myName;
    	// The rest is omitted.
    }

# Finish Execute

It can be terminated by calling FinishExecute(bool result) in the OnExecute method.

    1
    2
    3
    4
    	if (Input.GetKey(KeyCode.Space) )
    	{
    		FinishExecute(true);
    	}

# Data flow

It is possible to input / output values by data flow.

For details, see “Scripting: Data flow”.

Scripting : Data flow