- Import ChivalryBT.dll and ChivalryBTEditor.dll to Unity3d Project under Folder
Assets/Plugins
(Create if none).
- Select ChivalryBTEditor.dll, set the platform to Editor only, otherwise you can NOT build project.
After easy setup, now you can use ChivalryBT. Click here to know what is Behaviour Tree.
- Click menu GameObject->Behaviour Tree to create a template.
- Unfold ChivalryBT.dll and you'll see all nodes.
- Create an empty GameObject, then drag it under Sequence node which is just automatically created in step 1. Drag Log node to the empty GameObject. If success, the GameObject you just create will auto renamed as "Log".
- Pick Log node and set argument as "start".
- In the same way, create Wait(set argument as "1") and another Log(set argument as "finish") below. Now, there are 3 nodes under Sequence.
- Play game and see console's output.
Note: One GameObject can attach one node at most.
There are three types node in Behaivour Tree: Action, Compositer, Decorator.
public class YOUR_ACTION : Action
{
protected override void OnResetData()
{
base.OnResetData();
//execute before restart this action
}
protected override ActionState OnExecute()
{
//code here.
//ActionState has three values:Success,Failed,Running.
//if you execute a long-time action, such as Walk, you should return Running when not reach destination.
return ActionState.Success;
}
}
Variable support a way to share value in nodes. ChivalryBT gives some built-in variables such as Bool, Int, Float, etc. To use variables, refer steps below.
- Create a empty GameObject to hold variable, put it anywhere you like(under Variables GameObject is recommended.).
- Attach StringVariable component on the GameObject and set variable's value.
- Pick Log node, check the toggle right of the argument Log.
now, Log node's argument use the value of the StringVarialbe. If there's another node to change the value of that StringVariable, Log changes too.
ChivalryBT will set state of every executed node as prefix of their names.
- S = Success
- F = Failed
- R = Running