A visual editor extension for creating and managing Behaviour Trees used by the Turn Based Strategy Framework in Unity.
This package is not a standalone system — it enhances the Turn Based Strategy Framework by providing a visual workflow for authoring AI logic.
- Unity >= 6.2
- Turn Based Strategy Framework >= 4.0.2
- Graph Toolkit == 0.4.0-exp.2
- Install the Graph Toolkit, as described here: Graph Toolkit Installation Guide
- Download and import the latest release package from this repository.
The project includes a ready-to-use RegularBehaviourTreeGraph and a corresponding RegularBehaviourTreeProfile.
This AI behaves the same as the RegularBehaviourTreeResource included in the Turn Based Strategy Framework.
To quickly test the setup:
- Open the unit prefab and add an empty child GameObject.
- Add a
BehaviourTreeProfileAdaptercomponent to the new GameObject. - Assign the
BTEditor/RegularBehaviourTreeProfileto the Profile field. - Assign the
BehaviourTreeProfileAdapterto the BehaviourTreeResource field on your Unit prefab.
The unit will now use the RegularBehaviourTreeProfile as its AI.
For creating your own trees and profiles, see the sections below.
A Behaviour Tree defines decision-making logic as a hierarchy of nodes that control how an AI agent acts.
Understanding how Behaviour Trees work conceptually is beyond the scope of this README — basic familiarity is assumed.
The Turn Based Strategy Framework includes an implementation of Behaviour Tree–based AI, but by default these trees must be authored in code.
This editor provides a visual alternative.
- Behaviour Tree Graph – An asset edited in the Graph Toolkit editor.
Create via:Create → Turn Based Strategy Framework → Behaviour Tree Graph - Behaviour Tree Profile – A ScriptableObject that instantiates a specific Behaviour Tree Graph and provides parameterization for runtime use.
Create via:Create → Turn Based Strategy Framework → Behaviour Tree Profile - Behaviour Tree Profile Adapter – A component that attaches a Behaviour Tree Profile to a unit.
- Nodes – The functional elements of the tree.
The project includes implementations of all standard node types provided by the Turn Based Strategy Framework.
The editor interface is powered by the Graph Toolkit.
You can create and connect nodes, define variables on the blackboard, and arrange the graph visually.
For detailed guidance on Graph Toolkit usage, see the official documentation:
Graph Toolkit Manual
- Create a new graph via
Create → Turn Based Strategy Framework → Behaviour Tree Graph.
Double-click the new asset to open it for editing. - Add and connect nodes to define behaviour logic.
⚠️ Important: Each graph must start with aRootGraphNode. - Save the graph.
A graph acts as a template. Profiles create specific instances of that graph with adjustable parameters.
For example, you can derive multiple unit AIs—aggressive, defensive, cautious—by changing the profile’s variable values.
- Create a new profile via
Create → Turn Based Strategy Framework → Behaviour Tree Profile. - Assign the desired Behaviour Tree Graph to the Template field.
- Adjust parameter values in the inspector.
Repeat the same setup used in Getting Started for your custom profiles:
- Open the unit prefab and add an empty child GameObject.
- Add a
BehaviourTreeProfileAdaptercomponent. - Assign your chosen profile (for example,
BTEditor/RegularBehaviourTreeProfile) to the Profile field. - Assign the
BehaviourTreeProfileAdapterto the BehaviourTreeResource field on the Unit prefab.
The unit will now use the selected Behaviour Tree Profile at runtime.
To contribute to the development of the Behaviour Tree Editor:
- Clone this repository into your Turn Based Strategy Framework project folder.
- Open the project in Unity.
- Make your changes.
- Submit a pull request.
Q: Why isn’t the editor included directly in the framework?
A: The Graph Toolkit is an experimental package. I don’t want to require users to install experimental dependencies. Once a stable release is available, I will consider adding it directly to the project.
Q: Getting
NullReferenceException: Object reference not set to an instance of an object
TurnBasedStrategyFramework.Unity.Units.Unit.get_BehaviourTree()
A: You didn’t reassign the brain to the unit.BehaviourTreeResource field.
Q: I wrote a custom node and parameter values aren’t being passed to runtime nodes.
A: Make sure to add [SerializeField] to value fields and [SerializeReference] to reference fields in your runtime node classes.
Q: I added [SerializeField], but parameter values are still not being passed.
A: Save the graph again so Unity reimports it.
If you have any questions, feedback, or need assistance with the Behaviour Tree Editor, feel free to reach out. You can contact me directly via email at crookedhead@outlook.com for specific queries or suggestions. Additionally, for broader community support and discussions, join the TBSF Discord server: TBSF Discord. This platform is ideal for connecting with other TBSF users, sharing experiences, and getting help from the community.