Giter VIP home page Giter VIP logo

bt-framework's Introduction

BT-Framework

BT Framework is a simple behavior tree framework that can be used to create game AI. It's written for Unity3d.

Features

  1. Minimum dependencies on Unity3d, so it won't pollute your inspector.
  2. Extendable to handle customized logic nodes, though classic logic nodes, like sequence, priority selector, parallel, are provided.
  3. Communication between local nodes, cross-tree nodes, and other scripts are possible by the use of blackboard system.
  4. Enter, Execute, Exit api support for action nodes.

How to use

  1. Create various actions and pre-conditions inheriting from BTAction and BTPrecondition.

  2. Create a class inheriting from BTTree, and construct the behavior tree in Init function.

  3. Drag the class to a GameObject.

It's this simple!

A simple example:

// A class inheriting from BTTree
    
protected override void Init () {
   // Initialize base class
   base.Init();
   
   // Create root node
   _root = new BTPrioritySelector();
   
   // ---Construct the behavior tree---

   // Escape when boss is close
   DistanceClosePrecondition bossClose = new DistanceClosePrecondition("Boss");
   _root.AddChild (new DoRun(bossClose));
   
   // Fight when a goblin is close
   DistanceClosePrecondition goblinClose = new DistanceClosePrecondition("Goblin");
   _root.AddChild (new DoFight(goblinClose));
   
   // Do nothing when boss & goblin not around
   _root.AddChild (new Idle());

}

where DistanceClosePrecondition are user defined precondition that inherits from BTPrecondition, and

DoRun, DoFight, Idle are user defined behaviors that inherit from BTAction.

Example demos:

Ludum Dare 48-hour game jam entry: [Swordsman] (http://ludumdare.com/compo/ludum-dare-30/?action=preview&uid=24851)

Code Demo: [BT Test Improved] (https://github.com/f15gdsy/BT-Test/tree/improved)

Code Demo: [BT Test Original] (https://github.com/f15gdsy/BT-Test/tree/master)

Platformer Demo: [Archer] (https://dl.dropboxusercontent.com/u/27907965/games/Archer/Build_0/Build_0.html)

bt-framework's People

Contributors

f15gdsy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.