Skip to content
Sam Orme edited this page Jul 19, 2022 · 5 revisions

Documentation is a work in progress!

Splatter.AI is a code based behaviour tree for Unity projects.

Installation

To add to your Unity project go to the Package Manager, click the plus in the top left of the window. Select git URL and enter: https://github.com/ormesam/splatter.ai.git?path=/src/Assets/Splatter.AI

Quick Start

  1. Create new class deriving from BehaviourTree
  2. Override Awake method (optional) and initiate blackboard values, make sure to call base.Awake(); at the start of the method
  3. Override CreateRoot method, here you can build up your behaviour tree using the BehaviourTreeBuilder class as shown below
  4. Attach the script to the GameObject
  5. The tree will be executed every frame

Example

using Splatter.AI;

public class ZombieBehaviourTree : BehaviourTree {
    public override void Awake() {
        base.Awake();
        
        Blackboard[ZombieKey] = GetComponent<Zombie>();
    }
    
    protected override Node CreateRoot() {
        return new BehaviourTreeBuilder(this)
            .Sequence()
                .Name("root")
            	.Do("custom action", () => {
                    return NodeResult.Success;
                })
            .End()
            .Build();
    }
}
Clone this wiki locally