Skip to content

Behavior Tree using UI Builder, GraphView, and Scriptable Objects in Unity 2021.3

License

Notifications You must be signed in to change notification settings

JamesLaFritz/GraphViewBehaviorTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Repo Title and Info'
Report Bug · Request Feature

forks Badge stargazers Badge Contributors Badge issues Badge License Badge

Portfolio medium LinkedIn Itch.io

Logo

Table of Contents

  1. About The Project
  2. License
  3. Acknowledgements

About The Project

Product Name Screen Shot

I had code on sitting around on my hard drive for a Behavior Tree Editor That inspired me to create a bBehavior Tree Editor and write Articles about Behavior Tree and Using the Unity Editor UI Builder. It has been Pointed Out to me very polite and professional that this code is actually from the KIWI Coder.

The Kiwi Coder

Behavior Tree using UI Builder, GraphView, and Scriptable Objects in Unity 2021.3

This can be used as a template to build any type on Node Based Editor in Unity. i.e Dialog System or an AI Behavior Tree. If using for AI Behavior tree I would probably use Single Input Ports not Multiple. Even though the Nodes themselves are Scriptable Objects this can be changed and there is nothing that states that you have to use Scriptable Objects as the type for the nodes, this was just a decision that I made as it is easier to Bing the properties off the Node. Also there is nothing sating that the Nodes have to be stored in the Asset itself as I have done.

Behavior Tree is an execution tree (uses the Strategy pattern) and always starts with a Root Node. This will be so that the behavior tree knows where to start. Root Node has only one child. Now there are 3 basic main type of nodes Decorator, Composite Node and Action Node. Each Node can return one of three states Running, Success, or Failure. All nodes will be saved in Unity as Scriptable Objects. A Behavior tree will be a Scriptable Object containing all the Nodes in it.

Documentation

Decorator Node

  • Has one child and is capable of augmenting the return state of it's child. This uses the Decorator pattern.

Composite Node

  • Has a list of children and is the control flow of the behavior tree like switch statements and for loops. There are 2 types Composite Nodes the Selector and Sequence. This uses the Composite pattern.

Action Node

  • The Leaf of the tree, has no children, and is where all of the logic gets implemented.

Built With

Installation

To install this into your project for modifications Clone or Download the code from Git Hub into the Asset Folder of your project. Change the Folder From GraphView Behavior Tree to mach what you wold like. Edit all Files and change the NameSpace to match your new Folder Name. Do Not forget to change this in the UXML Documents as well. i.e "GraphViewBehaviorTree.Editor.SplitView" Delete the Runtime/james.lafritz.GraphViewBehaviorTree and Editor/james.lafritz.GraphViewBehaviorTree.Editor Assembly Definition Files, Or Edit/Replace them with your own.

To use Template as is Use the Package manager to Install package from Git Hub. see Creating custom packages for use in Unity

Articles

Behavior Trees In Unity

Using Unity’s UI Builder: Basic Set Up

Using Unity’s UI Builder: Serialized Object data binding

Using Unity’s UI Builder: Adding Custom Controls

Using Unity’s Graph View: Adding and Deleting Nodes

Using Unity’s Graph View: Node Position, Code/Editor Window Reload

Using Unity’s Graph View: Connecting Nodes in The Editor

Inspector View in an Editor Window

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

The Kiwi Coder Behavior Tree Editor The Kiwi Coder

About

Behavior Tree using UI Builder, GraphView, and Scriptable Objects in Unity 2021.3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages