BehaviourRunner

Type description and basic instructions.

class in RenownedGames.AITree / Inherits from ScriptableObject

Main component to run created behaviour tree assets. Use Behaviour Runner component to access associated behaviour tree and blackboard of related AI entity at the scene.

Example

[RequiredComponent(typeof(BehaviourRunner))]
public class Example : MonoBehaviour
{
    [SerializeField]
    private string keyName;

    private void Awake()
    {
        // Get gameobject runner.
        BehaviourRunner runner = GetComponent<BehaviourRunner>();
        
        // Get associated instance of blackboard.
        Blackboard blackboard = runner.GetBlackboard();
        
        // Find key by name and set custom value.
        if(blackboard.TryFindKey<TransformKey>(keyName, out TransformKey key))
        {
            // Set this transform refrence as key value.
            key.SetValue(transform);
        }
    }
}

Virtual Methods

// Called when an enabled script instance is being loaded.
protected virtual void Awake();

// Called on the frame when a script is enabled,
// just before any of the Update methods are called the first time.
protected virtual void Start();

// Called every frame, if the Behaviour is enabled.
protected virtual void Update();

// Called every fixed frame-rate frame. 0.02 seconds,
// is the default time between calls, if the Behaviour is enabled.
protected virtual void FixedUpdate();

// Called every frame, if the Behaviour is enabled.
protected virtual void LateUpdate();

// Called when an enabled script instance is being destroyed.
protected virtual void OnDestroy();

// Implement if you want to draw gizmos,
// that are also pickable and always drawn.
protected virtual void OnDrawGizmos();

// Implement to draw a gizmos if the object is selected.
protected virtual void OnDrawGizmosSelected();

Getter / Setter

// Shared reference of behaviour tree.
BehaviourTree GetSharedBehaviourTree();

// Associated instance of behaviour tree.
BehaviourTree GetBehaviourTree();

// Shared reference of blackboard.
Blackboard GetSharedBlackboard();

// Associated instance of blackboard.
Blackboard GetBlackboard();

Last updated