-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Sam Orme edited this page Jul 19, 2022
·
5 revisions
Splatter.AI is a code based behaviour tree for Unity projects.
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
- Create new class deriving from BehaviourTree
- Override
Awake
method (optional) and initiate blackboard values, make sure to callbase.Awake();
at the start of the method - Override
CreateRoot
method, here you can build up your behaviour tree using theBehaviourTreeBuilder
class as shown below - Attach the script to the GameObject
- The tree will be executed every frame
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();
}
}