Behavior Tree Barebones Tutorial

This isn’t even a Unity specific question, but does there exist in ANY language a tutorial based in teaching how to program the basic structure of a behavior tree. I mean, like even the most barebones example. I know AI is a complicated, non-trivial topic and I’m not expecting anyone to teach me “how do I do enemy ai?” I just LITERALLY cannot find any implementation of this out there or any tutorial explaining the code in plain English.

Please note: I am not a novice programmer. I realize there are thousands of ways to probably implement a behavior tree, I’m just looking for one good example so I can start my own for my game.

Please also note: I’m specifically avoiding AngryAnt’s Behave because, although it looks like a good tool, I don’t agree with his licensing and would really just like to take initiative as a programmer and learn for myself.

Thanks. :3

A short search on Google will provide you with a decent stack of information on that subject, albeit you have to sift through it a bit.

But anyway here are some very use full links on the topic, its some overview on how BTs work and how they are built (not entirely specific to building in Unity):

http://altdevblogaday.com/2011/02/24/introduction-to-behavior-trees/
http://www.pixelstudio.nl/?p=146
http://aigamedev.com/open/article/bt-overview/
http://aigamedev.com/insider/tutorial/second-generation-bt/

also its not a bad idea to look at existing behavior trees and dissecting them to see how they work.

Here’s a recently released open source library for Unity3D

Given that unity serialization is broken, and does not support polymorphism in collections I would say it is a hard thing to make. And if you take the ScriptableObjects route, you will weep in agony, and be ashamed of the code you will have to spit out in order for it to ‘almost work’.
I dont know why, but unity developers think that polymorphism and serialization is not needed in object oriented programming.

They said that it is “too hard to implement”. Say that to your boss and see what happens…

Also try Full Inspector from the asset store. It will help.

Have a look at Panda BT:
http://www.pandabehaviour.com/

There’s also a video tutorial here: Woodcutter AI in Unity 3D using Panda Behaviour Tree - YouTube

It’s a script-based behaviour tree engine; you define your tasks as C# functions, then use them while writing BT scripts to define your behaviour trees. Also, you can visualize the execution of tree at runtime, which is useful to debug or simply to have a detailed look at what the AI is currently doing.

The Panda BT package contains examples, from simple to complex, which you could toy around to get a feeling about this tool.

I’m currently implementing one for my AI module, I can send you it once I’m done if you want :slight_smile: