Member-only story
Making a RTS game #24: Implementing behaviour trees for our units 2/3 (Unity/C#)
Today, we’ll continue working on the behaviour trees for the units of our RTS!
⬅️ Tutorial #23: Implementing behaviour trees for our units 1/3| TOC | Tutorial #25: Implementing behaviour trees for our units 3/3 ➡️
📕 Get the ebook and bonus material on Gumroad!
🚀 Find the code of this tutorial series on my Github!

In the last episode, we introduced the concept of behaviour tree (BT) and we saw how this tool can help us model complex AI systems like the one for our RTS units. We also compared it to another task switching structure, the finite state machine.
Now, it’s time to actually get to coding and see how BTs can be implemented in Unity. And to begin with, let’s start by creating a little toolbox of basic BT objects to then choose from easily.
Preparing the behaviour tree utilities
So, for now, we’re not going to implement the actual behaviour trees of our RTS units yet… but we’ll make sure that we have everything ready for the next section!
We are going to code up the base objects of a BT, the Node
and the Tree
class; the usual composites: the…