uScript

uScript is a visual scripting tool which allows you to create complicated setups without needing to write a single line of code. Behavior Designer integrates directly with uScript by allowing uScript to carry out the action or conditional tasks and then resume the behavior tree from where it left off. uScript integration files are located on the downloads page because uScript is not required for Behavior Designer to work.

To get started, first make sure you have uScript installed and have imported the integration package. Once those files are imported you are ready to start creating behavior trees with uScript . To get started, create a very basic tree with a sequence task who has two Start Graph child tasks:

Now we need to create two GameObjects which will hold the compiled uScript graph:

Open uScript and start creating a new graph. Add the Behavior Tree Signal node, located under Events/Signals. When Behavior Designer wants to start executing a uScript graph it will start from this node. This node contains four events: Start Signal, Pause Signal, Resume Signal, and End Signal. Start Signal is used when the behavior tree task starts running. Pause Signal gets called when the behavior tree is paused, and the Resume Signal gets called when the behavior tree resumes from being paused. Finally, End Signal gets called when the uScript task ends. For our graph we are only going to create a few nodes, the uScript sample project shows a more complicated uScript graph. Create a node which has a delay of 3 seconds, sets a bool, then resumes the behavior tree. The Resume Behavior Tree node is located under Actions/Behavior Designer:

Now we need to create a Owner GameObject and bool variable.

Save the uScript graph and assign the component to your first uScript graph GameObject. Answer no if uScript asks if you want to assign the component to the master GameObject.

Create one more uScript graph. Make it the same as the last graph except set the bool to false:

Finally save that graph and assign the component to the second uScript GameObject:

We’re almost done. The only thing left to do is to assign the correct uScript GameObject to the tasks within Behavior Designer. Open your behavior tree within Behavior Designer again. Click on the left uScript task and assign the uScript GameObject to your first uScript graph GameObject.

Do the same for the right uScript task, only assign the uScript GameObject to your second uScript graph GameObject. That’s it! When you hit play you’ll see the first uScript task run for three seconds, followed by the second uScript task.

If you were to swap the tasks so the second uScript graph runs before the first uScript graph, the behavior tree will never get to the first uScript graph because the second uScript graph returned failure and the sequence task stopped executing its children.