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.

Getting Unity Web Player to work on Mac Lion

I have been getting back into using Unity 3D, which I believe is a very useful and insightful tool, but I have been having trouble getting the Web Player to work. For some reason, when I would install it, Safari wouldn’t recognize that it was installed, even after  restarting Safari.

Turns out that when the web player was being installed, it was being installed in the Unused Folder inside the plugins directory. So to fix it was as simple as moving it up a directory. Huh, funny bug.