Search Unity

Fluid Behavior Tree - Code Driven Behavior Trees

Discussion in 'Assets and Asset Store' started by Ash-Blue, Jun 1, 2019.

  1. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    Fluid Behavior Tree is a code driven Unity behavior tree library for Unity. It's easily extendable and utilizes the builder pattern.

    Feature Highlights
    • Unity Package Manager friendly
    • No 3rd party plugins
    • 140 unit tests and growing for good code coverage
    • Pre-built library of tasks to kickstart your AI
    • Tracks the last position of your behavior tree and restores it the next frame
    • Built for Unity (works as soon as you install it)
    • Code base is easily extendable to add your own custom nodes
    Behavior Tree Example

    Code (CSharp):
    1. using UnityEngine;
    2. using CleverCrow.Fluid.BTs.Tasks;
    3. using CleverCrow.Fluid.BTs.Trees;
    4.  
    5. public class MyCustomAi : MonoBehaviour {
    6.     private BehaviorTree _tree;
    7.  
    8.     private void Awake () {
    9.         _tree = new BehaviorTreeBuilder(gameObject)
    10.             .Sequence()
    11.                 .Condition("Custom Condition", () => {
    12.                     return true;
    13.                 })
    14.                 .Do("Custom Action", () => {
    15.                     return TaskStatus.Success;
    16.                 })
    17.             .End()
    18.             .Build();
    19.     }
    20.  
    21.     private void Update () {
    22.         // Update our tree every frame
    23.         _tree.Tick();
    24.     }
    25. }
    Extending Behavior Trees

    Code (CSharp):
    1. using UnityEngine;
    2. using CleverCrow.Fluid.BTs.Tasks;
    3. using CleverCrow.Fluid.BTs.Tasks.Actions;
    4. using CleverCrow.Fluid.BTs.Trees;
    5.  
    6. public class CustomAction : ActionBase {
    7.     protected override TaskStatus OnUpdate () {
    8.         Debug.Log(Owner.name);
    9.         return TaskStatus.Success;
    10.     }
    11. }
    12.  
    13. public static class BehaviorTreeBuilderExtensions {
    14.     public static BehaviorTreeBuilder CustomAction (this BehaviorTreeBuilder builder, string name = "My Action") {
    15.         return builder.AddNode(new CustomAction { Name = name });
    16.     }
    17. }
    18.  
    19. public class ExampleUsage : MonoBehaviour {
    20.     public void Awake () {
    21.         var bt = new BehaviorTreeBuilder(gameObject)
    22.             .Sequence()
    23.                 .CustomAction()
    24.             .End();
    25.     }
    26. }
    If you have questions or need help getting started feel free to post here. You can also join us on Discord. Source code available at GitHub.
     
    Last edited: Jun 2, 2019
    CrazyD0G likes this.
  2. vet-cat

    vet-cat

    Joined:
    May 29, 2013
    Posts:
    37
    thanks, great job
     
  3. unicoea

    unicoea

    Joined:
    Feb 18, 2013
    Posts:
    60
    Great BehaviorTree for unity3d! Please add support for ScriptableObject.
     
  4. unicoea

    unicoea

    Joined:
    Feb 18, 2013
    Posts:
    60
    Hi!
    Can you tell what unity version suit for each version of Fluid Behavior Tree?
    for example, i use unity2018.4.18, which Fluid Behavior Tree version is best fit?
     
  5. unicoea

    unicoea

    Joined:
    Feb 18, 2013
    Posts:
    60
    Hi!
    I import it into project with package manager, it is easy to install, but when i change the folder name of my project and open again, it said path not find. How can i change the path to relative path?

    Thank you!
     

    Attached Files:

  6. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    @unicoea oh hey, I usually do support requests on Discord or through the GitHub issues page. Ping me there and I can help. I find these things require quite a bit of back and forth to debug sometimes.