25 Aug 2013

Behave 2.0

In 2010 the Unity Asset Store launched with an editor extension already live. That extension was Behave 1. Three years later, after way too long a pause, I have finally gotten around to releasing version 2.0 of Behave.

As you might have noticed, especially lately, I have had quite a few things going on – not the least of which is my recent exit from Unity Technologies and entry into freelancing. This all meant not a lot of time for Behave.

So anyway, this is what I was doing when I was not writing that Unity Hacks blog post you were waiting for.


If you have no idea what Behave is and don’t feel like dropping by the subsection on this site dedicated to it, here is how it is defined on the Asset Store:

Behave is a system for designing, integrating and running behaviour logic using Behaviour Trees. At its core Behave has a drag-drop designer and a highly effective and flexible compiled runtime.

No funky runtime data formats or interpretation. Designer → Compiler → Your code.

What is the use of a workflow extension without proper rapid iteration tools? Connect the visual debugger with break, step, reset, breakpoints and overrides directly to your project in the editor or on your target device.

Update: An introductory video to Behave 2 is now available:


Part of the challenge with any project is always to fight feature creep. This was very much also the case with Behave 2, so don’t worry – I have plenty of improvements to come. Not saying that this build is broken though – go get it!


Unlike Behave 1, version 2 is a paid package. Aside from having gone freelance and needing a financial basis to keep up support for the software, this also had to be done as the Asset Store long ago banned the use of custom licenses.

This, of-course posed a bit of a problem for Behave 1’s default “free if you show the splash” license. Fortunately the Asset Store team members are merciful gods and I got a veeery long grace period to beat Behave into compliance.

Included in the license is also access to a private community and internal support resources – including the beta list.


For a limited time after launch, Behave 2 will be available at a flat discount of 50%. Additionally, if you happen to bump into me at Unite 2013 in Vancouver next week, you can slip me your business card and partake in the draw for one of three free Behave 2 licenses.

If you already purchased a copy of Behave 2 and win a free copy, I’ll refund you the purchase amount.

Update: Details of the Unite license draw are available here.


So if you are a Behave 1 user and you are wondering what exactly is under the hood, I included the full Behave changelog below.

Now you might go “1.5? What the hell? Did I miss something?”. No you did not. That version unfortunately did not ship, but was in stead rolled straight into 2.0. But hey, water and bridges, right? 2.0 is here baby!

Behave 2 for Unity on the asset store.


 - New editor.
	- Unified all controls into one window.
	- Completely customised look - compatible with both Unity light and dark skin.
	- Keyboard authoring interface in addition to drag & drop.
 - Debugger upgrade.
	- Remote debugging.
	- Tick and reset.
	- "Unplug" for debugger-only control.
	- Breakpoints.
	- Action overrides - override the return values of specified actions.
 - Decorator rewrite.
	- Deprecated old decorator.
	   - Still compiles, but cannot be added.
	- Decorators are now control-type components.
	   - No specific decorator handlers on agents.
	   - Control is achieved via third connection socket.
	- Two initial decorator types: Repeater and Interrupter.
 - Asset restructuring.
	- No more collections - for nesting, use paths in tree names.
	- New serialization format - see Readme.txt for upgrade instructions.
	- Collections are gone. Use Unix-style path names for tree organisation.
 - IAgent.Tick (Tree, bool) changed to IAgent.Tick (Tree)
	- Init calls can now only be handled explicitly
 - Full coverage online documentation and other community resources.
 - Countless fixes and polish items.

 - Added Tree.TickActive - indicating if a tree is currently executing a tick or if it has completed evaluation.
 - In-tick tree reset requests now result in a reset at the end of tree evaluation rather than an immediate one.
 - Removed the legacy compatibility assembly (for compatibility with pre-1.2 assets) from the default distribution.
 - Fixed "X must be instantiated using the ScriptableObject.CreateInstance method instead of new X" warnings.

 - Fixed decorator incorrectly initializing on every returning tick when tick handler returned Running.
 - Fixed debugger view dependency on active tree editor - causing reported null reference exception.
 - Fixed missing scrollbars on browser window.
 - Reduced logging noise from debug builds.
 - Agent blueprints can now be MonoBehaviour based.
 - Clarified wording on "library not loaded".
 - Now handling reset a bit cleverer - potential performance boost.
 - Changed the default success criteria of Parallel components from SuccessOrFailure to Success.
 - Added "instant" flag to components. Components marked instant will affect sequences and selectors when moving between child nodes. When a child node marked "instant" completes, rather than waiting for the next tree tick to tick the following child node, the sequence or selector does it immediately.
 - The compiler progress bar returns.
 - Editing a Behave asset now focuses the asset browser last instead of the tree editor.
 - Behave can now be installed in any subfolder of Assets - provided its internal folder structure remains intact.
 - Compilation speed improvements.
 - Enabled references across collection borders.
 - Added Tree.DataSize - returning the number of bytes used by a tree instance. This is also displayed in the debugger window.

 - Fixed priority selector init flag resetting.
 - Fixed reference handling on tree renaming and deletion.
 - Fixed references still pointing at old collection post collection duplication.
 - Fixed compilation of actions and decorators with non-integral float parameters.
 - Fixed GUI list behaviours.
 - Fixed passing context back and forth between referenced trees and referrer.
 - Fixed reordering connections not causing save state to be set.
 - Various GUI tweaks.
 - Runtime optimisations.
 - Enabled scrolling of the tree list in the debugger window.
 - Exposed Tree.ReflectForwards.
 - Added Tree.ResetForwards.
 - Added agent blueprints - connecting to agent handlers through virtual methods rather than reflected handlers.
 - Made connections selectable in the tree editor via the connection nub.
 - Moved connection managing from the inspector to the tree editor, where it is more visible and handy.
 - Added support for disabling connections - for faster, less destructive debugging.
 - Double-click reference component to jump to referenced tree.
 - Changed "Cannot update unregistered tree" handling from an exception to an error message. Still need more info.
 - Now showing string and float parameters in the tree editor if either is set.

 - Fixed release building.
 - Added the priority selector, introducing the API points:
	- int IAgent.SelectTopPriority (Tree sender, params int[] IDs);
	- enum BL[LibraryName].PriorityType { PriorityName, ..., Unknown };
 - Added support for branch contexts, introducing the API points:
	- enum BL[LibraryName].ContextType { ContextName, ..., Unknown };
	- int Tree.ActiveContext { get; }
 - Changed IAgent interface:
	- Tick (bool init, Tree sender) -> Tick (Tree sender, bool init)
 - Added "Select asset" button to the standard inspector.
 - Interface polish.

 - Made compatible with Unity 3.0 - including ensuring that the 2.5-2.6.1 bug preventing compilation on Windows is fixed on the Unity side.
 - UI tweaks and polish.
 - Added the option to have return values of nodes be inverted.
 - Fixed compiler bug when facing sequence or selector with only one child node.
 - Renamed Library.Tree -> Library.InstantiateTree.
 - Added Tree.Tick () and Tree.Reset () methods using the IAgent instance given at instantiation of the tree.
 - Removed the abstract Library class.
 - Changed generated library class:
	- Trees -> TreeType.
	- Actions -> ActionType.
	- Decorators -> DecoratorType.
	- Tree InstantiateTree (int, IAgent) -> static Tree InstantiateTree (TreeType, IAgent)
	- int TreeID (Tree) -> static TreeType Type (Tree)
	- bool IsAction (int) -> static bool IsAction (int)
	- bool IsDecorator (int) -> static bool IsDecorator (int)
 - Upped editor performance.
 - New asset structure change with automatic import of Behave 1.0 assets.
 - Changed action and decorator handlers. These are now the handlers mapped:
	- public BehaveResult Init[Name][Action/Decorator] (Tree sender, string stringParameter, float floatParameter, IAgent agent, object data);
	- public BehaveResult Tick[Name][Action/Decorator] (Tree sender, string stringParameter, float floatParameter, IAgent agent, object data);
	- public void Reset[Name][Action/Decorator] (Tree sender, string stringParameter, float floatParameter, IAgent agent, object data);
	- public BehaveResult Init[Name][Action/Decorator] (Tree sender);
	- public BehaveResult Tick[Name][Action/Decorator] (Tree sender);
	- public void Reset[Name][Action/Decorator] (Tree sender);
	- public BehaveResult [Name][Action/Decorator] {get; set;}
 - Added support for collection duplication.
 - Moved debug rendering into the editor with its own dedicated debugger window, including actor listing.
 - Debugger now renders active sub-trees as well.

 - Lots o fixes for Unity 2.5 compatibility.
 - Closer editor integration with new UI.
	- Component bar.
	- Node inspection.
 - Runtime tree debugging.
 - Direct mapping of action and delegate handlers via reflection.
 - Kitty demo.

 - Various tweaks to the editor UI.
 - Optimised the compiler.
 - Fixed the following editor bugs from the bug list:
	- When the editor scrips are recompiled and when the user enters and exits play mode, running editors will loose references, causing undetermined behaviour.
	- When a compile fails, the Behave compiler is locked and unusable – requiring a unity relaunch.
 - Implemented the following wishlist items:
	- Behaviour tree decorators.
	- Stand-alone edition of the Behave editor.
	- Behaviour tree debugging features.

 - Made the demo project a whole lot more interesting.
 - Implemented the editor wish list item: Ability to move trees between collections.
 - Various tweaks to the editor UI.
 - Fixed a ton of bugs in the compiler.
 - Fixed the following editor bugs from the bug list:
	- Not able to delete collections from library.
	- Not able to delete trees from library.
	- Not able to rename collections from library.
	- Not able to rename trees from library.
	- Missing "tree has been changed, save changes?" dialog.

 - Some documentation is available.
 - Compiler is now creating sensible output.
 - A simple test tree and script using it is provided with the demo.
 - Documentation is linked directly from the unity help menu.
 - Less spamming of the log with debug information.

 - Magic happened. Behave was born.
New Gear
Unity, iOS, TeamCity, AppCenter
RAID0 NVMe on Ubuntu
A Change of Gears
Unity Protocol Buffers
Behave 2.7
Behave 2.6
Trusted Gear
Mad Mash Versioning
Behave 2.5
Behave 2.4
The Engine Wars: Numbers
GDC 14: The Quest For Fun
Moving in Unity
Behave 2.3
Unity and .net assemblies
Behave 2.2
Behave 2.1
Behave 2.0
Unity Hacks: Dual sticks
Unity Hacks: Cameras
Unity Hacks: Touch gestures
Unite 13 video "Unity Hacks" available
The implicit local network interface
Talks and progress
Five years of Unity expertise looking for contracts
Automagic Unity Android Java gadget OF DOOM!
Invading Planet from your couch
Mountain Lion and laggy bluetooth and duct-tape
Unite 12 video and new videos section available
Asia Bootcamp videos now available
Path is now MIT licensed
Behave 1.4 released
So I've been a bit busy lately
Behave 1.3 released
IGDA Unity SIG slides
Second Unity IGDA SIG this evening: Scene construction and AI
First IGDA Unity SIG this evening
Alternative licensing available
Pathfinding in two lines
Path 2 released
Assembling and assimilating
Path 2 intro screencast
Path 2 beta release for GGJ
AIgameDev master class video now online
Expanding beta
Behave AIgameDev master class public stream
Behave master class on open AIgameDev stream tomorrow
Interview with AIGameDev
New video: From tree to code
Issue tracking on github Behave release project
IT University Copenhagen Unity course completed
IT University Copenhagen Unity course files Thursday
CPH IT University Unity course files
Behave 1.2 released
Video: Behave - starting from scratch
Behave runtime documentation updated
Behave 1.1 released
FAFF cleanup: Sketch
Building a menu of delegates and enums
Pick me! Pick me!
Optimising coroutine yielding in C#
Downloading the hydra
New license of Path: GPL
GUI drag-drop
Logging an entire GameObject
I bet you can't type an A!
Where did that component go?
New and improved: Behave 1.0 released
Behave 0.3b and unity 2.5
Behave 0.3b hotfix
Path tutorial video available
Path 1.0 launched!
Continued community tutorials
Community tutorial
New tutorial
First tutorial available
Behave 0.3b
unite '08 open-mic session
Behave 0.2b
Behave 0.1b
Behave pre-release
Path beta 0.3b
Path beta 0.2b
Path beta 0.1b
Path pre-release