Using Angry Ant’s Behave Library in UnityScript

I have been learning how to use Unity3D recently, and I really wanted to use the Behave library without having to use C#. It took me a little while, but here is an example of doing it:

#pragma strict


// Where we store our new Behave Tree

var BTree : Behave.Runtime.Tree;


// Where we store our Behave IAgent

var Agent : BSIAgent;


// Where we implement all of our Behave level functions

public class BSIAgent implements Behave.Runtime.IAgent {


public function Tick (sender : Behave.Runtime.Tree, init : System.Boolean) {


return Behave.Runtime.BehaveResult.Success;



public function Reset (sender : Behave.Runtime.Tree) {



public function SelectTopPriority (sender : Behave.Runtime.Tree, IDs : int[]){

return IDs[0];




function Start() {

// Create a new agent

Agent = new BSIAgent();

// Create our tree

BTree = BLBasicMiner.InstantiateTree( BLBasicMiner.TreeType.Task_Systems_BasicTS,   Agent   );

// While the application is running and our tree exists

while (Application.isPlaying && minerTree != null) {

// Wait for a certain amount of time

yield new WaitForSeconds(1.0f / minerTree.Frequency);

// Tick the tree





function AIUpdate() {



Yes, this is a bit of a hack, but I haven’t had much time to refine it. Hopefully in the future I will be able to provide a more readable version.

Update: Kernel Development

I decided that I was going to convert my c code into c++ today. Big mistake. C code does not and cannot be directly converted into C++ code, at least in this case. I was running around, trying to get all of my void * casts to work, getting const char * casted… blearg. I just gave up and I am returning to C.

Maybe in the future I will try to write a kernel from scratch in C++ because I could see objects being very useful.

Kernel Development – Amazing!

I have recently started a journey into the world of Kernel Land… That was an eye opener. I never realized how complex operating systems were before I decided to roll my own from scratch.

Currently I am at the point where I can accept input from the keyboard and display it on the screen in Mode 7. I am working on a floppy driver right now, and am going to work on File Systems after that.

I have been developing it for fun, in all actuality, but know that I know a little bit more I am going to put a bit of effort into making something a bit different than Linux or Mac or Windows ( At least as different as I can make it.) Probably something that is more pointed towards multi-core CPUs from the get-go.

I started learning by using Bona Fide OS Developer tutorials and the OSDev wiki. These are very good resources for the beginner, in my opinion.