Customize ActionBehaviour


This is the documentation for Arbor 3.2.4 and earlier.

See Arbor Documentation for the latest documentation.

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.
    http://arbor-docs.caitsithware.com/en/components/behaviourtree.html
  • OnAbort
    Called when the node is interrupted by the Decorator.
  • OnEnd
    Called when the action node exits.

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.

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.
}

You can also use CalculatorSlot and Flexible classes as well as StateBehaviour.

Finish Execute

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

if (Input.GetKey(KeyCode.Space) )
{
	FinishExecute(true);
}