Skip to content

ChivalryBT is a Behaviour Tree plugin for Unity3D.

Notifications You must be signed in to change notification settings

teddyzhang29/ChivalryBT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setup

  1. Import ChivalryBT.dll and ChivalryBTEditor.dll to Unity3d Project under Folder Assets/Plugins (Create if none).
    Figure1
  2. Select ChivalryBTEditor.dll, set the platform to Editor only, otherwise you can NOT build project.
    Figure2

Usage

After easy setup, now you can use ChivalryBT. Click here to know what is Behaviour Tree.

Basic

  1. Click menu GameObject->Behaviour Tree to create a template.
  2. Unfold ChivalryBT.dll and you'll see all nodes.
  3. 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".
  4. Pick Log node and set argument as "start".
  5. 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.
    Figure3
  6. Play game and see console's output.

Note: One GameObject can attach one node at most.

Custom Node

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

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.

  1. Create a empty GameObject to hold variable, put it anywhere you like(under Variables GameObject is recommended.).
  2. Attach StringVariable component on the GameObject and set variable's value.
  3. Pick Log node, check the toggle right of the argument Log.
    Figure4

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.

Debug

ChivalryBT will set state of every executed node as prefix of their names.
Figure5

  • S = Success
  • F = Failed
  • R = Running

About

ChivalryBT is a Behaviour Tree plugin for Unity3D.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages