MIT License

项目介绍

bitbrain/beehave 是一个托管在 GitHub 上的开源项目,主要使用 GDScript 编写,采用 MIT License 许可证,目前获得 3.3k 个 Star、175 次 Fork。

仓库全名
bitbrain/beehave
开源许可证
MIT License
Star 数
3.3k
Fork 数
175
未关闭 Issue
28

README 摘要

🐝 Behaviour Tree addon for Godot Engine! 🤔 Yet another Behavior Tree addon? There are already various behavior tree addons for Godot on the asset store, however, for my personal game none of them either worked correctly or they were UI only. I stumbled upon this amazing minimal behaviour tree example by @viniciusgerevini. I decided to fork it and create this addon from it for the following reasons: dedicated repo…

完整内容见 GitHub 原始 README 或本页 。

常见问题

beehave 用什么语言开发?

主要使用 GDScript 编写,采用 MIT License 许可证,目前有 3.3k 个 Star。

beehave 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 beehave 的源码?

可以直接克隆仓库:git clone https://github.com/bitbrain/beehave.git;安装与运行步骤见仓库 README。

beehave 最近还在维护吗?

仓库最近一次更新为 9月21日,当前有 28 个未关闭 Issue;Star 数为 3.3k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

🐝 behavior tree AI for Godot Engine

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
3694
价值分
2045
活跃状态
活跃

语言占比

Batchfile
C#
CSS
GDScript
HTML
Shell

Release

README

logo

🐝 Behaviour Tree addon for Godot Engine!

🤔 Yet another Behavior Tree addon?

There are already various behavior tree addons for Godot on the asset store, however, for my personal game none of them either worked correctly or they were UI only. I stumbled upon this amazing minimal behaviour tree example by @viniciusgerevini. I decided to fork it and create this addon from it for the following reasons:

  • dedicated repo for the addon including Godot 3.x and 4.x support
  • additional features such as a debug view in editor (see #1)
  • I am building an RPG and will have to heavily extend this addon to my needs

If you are looking for a simplistic addon without any extra fluff, Beehave is just right for you!

🧪 Installation

  1. Download for Godot 3.x or Download for Godot 4.x
  2. Unpack the beehave folder into your /addons folder within the Godot project
  3. Enable this addon within the Godot settings: Project > Project Settings > Plugins

📚 Getting started

Behaviour trees are a modular way to build AI logic for your game. For simple AI, behaviour trees are definitely overkill, however, for more complex AI interactions, behaviour trees can help you to better manage changes and re-use logic across all NPCs.

example

What is a behaviour tree?

In a nutshell, a behaviour tree is a Godot Node that can be added as a child to other Godot nodes within the scene tree. It will run its logic every frame tick and modify the parent node accordingly.

In more theoretical terms, a behaviour tree consists of so called nodes - each node can be of a different type with different purposes. Those are described further down below in more detail. Every node has a tick(actor, blackboard) method that can be used to execute custom logic. When the tick function is called, beehave expects a return status of either SUCCESS, RUNNING or FAILURE.

Tutorial (Godot 3.5+)

I have recorded this tutorial to show in more depth how to use this addon:

tutorial-thumbnail

Actions and Conditions

Conditions are leaf nodes of type ConditionLeaf. They should be kept simple and either return SUCCESS or FAILURE depending on a single condition. Avoid creating conditions that check multiple things as it will become more difficult to reuse these nodes.

1. Example Condition code: IsVisibleCondition.gd

class_name IsVisibleCondition
extends ConditionLeaf

func tick(actor, blackboard):
    if actor.visible:
        return SUCCESS
    return FAILURE

Actions are leaf nodes of type ActionLeaf. They can be long running potentially being called across multiple frame executions. In this case return the code RUNNING .

2. Example Condition code: MakeVisibleAction.gd

class_name MakeVisibleAction
extends ActionLeaf

func tick(actor, blackboard):
    if actor.visible:
        return FAILURE
    actor.visible = true
    return SUCCESS

The blackboard is an object that can be used to store and access data between multiple nodes.

Composites

In order to create logic flows based on conditions and actions, we need to compose them through so called composites. A composite is a node that executes its children in a particular manner as described below.

Selector

Selector nodes will attempt to execute each of its children and reports SUCCESS status code in case one of the children reports a SUCCESS status code. In case all children report a FAILURE status code, this node will also return FAILURE status code. This node will attempt to process all its children every single tick, even if one of them is currently RUNNING already.

Selector Star

The Selector Star node is similar to the Selector, however, it will skip all previous child nodes that were executed prior, in case one of the children is currently in RUNNING state. A usecase for this is if you want to ensure that only one action is executed at a time, regardless of for long it runs.

Sequence

Sequence nodes will attempt to execute all of its children and reports SUCCESS status code in case all of the children report a SUCCESS status code. In case at least one child reports a FAILURE status code, this node will also return FAILURE status code. This node will attempt to process all its children every single tick, even if one of them is currently RUNNING already.

Sequence Star

The Sequence Star node is similar to the Sequence, however, it will skip all previous child nodes that succeeded prior, in case one of the children is currently in RUNNING state. A usecase for this is if you want to ensure that only one action is executed at a time, regardless of for long it runs.

Decorators

Decorators are nodes that can be used in combination with any other node described above.

Failer

A failer node will always return a FAILURE status code.

Succeeder

A succeeder node will always return a SUCCESS status code.

Inverter

A inverter will return FAILURE in case its child returns a SUCCESS status code or SUCCESS in case its child returns a FAILURE status code.

Limiter

The limiter will execute its child x amount of times. When the number of maximum ticks is reached, it will return a FAILURE status code.

🍻 Contributing to this project

In case you want to suggest improvements to this addon or fix issues, feel free to raise a pull request or raise an issue!

Version management

The current godot-3.x branch is aimed for Godot 3.x while any Godot 4.x features should go into the godot-4.x branch. When raising pull requests, make sure to also raise a Godot 4 relevant version against godot-4.x if requested.

🖤 Credits

评论

暂无评论