在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:luis-l/BonsaiBehaviourTree开源软件地址:https://github.com/luis-l/BonsaiBehaviourTree开源编程语言:C# 100.0%开源软件介绍:Bonsai Behaviour TreeAdvanced behavior tree solution with a graphical editor Goals of the project
Features Overview:
Behaviour tree running. Editor Features and LimitationsDuring Play mode you can view how the a tree executes and see which nodes are running, the statuses returned (sucesss, failure, aborted, interrupted). You can also edit certain properties of a node, like changing the abort type, or setting a new waiting time for the wait task via the Unity Inspector. Things that cannot be currently edited in Play mode:
Overview
API and Custom TasksThese are the base nodes which can be extended:
In order to add custom functionality you can override key methods: // Called only once when the tree is started.
public virtual void OnStart() { }
// The logic that the node executes.
public abstract Status Run();
// Called when a traversal begins on the node.
public virtual void OnEnter() { }
// Called when a traversal on the node ends.
public virtual void OnExit() { }
// Called when a child caused an abort.
public virtual void OnAbort(ConditionalAbort aborter) { }
// Call when a child finished executing
public virtual void OnChildExit(int childIndex, Status childStatus) { } Example of a simple, custom Wait task: [BonsaiNode("Tasks/", "Timer")]
public class Wait : Task
{
private float timer = 0f;
public float waitTime = 1f;
public override void OnEnter()
{
timer = 0f;
}
public override Status Run()
{
timer += Time.deltaTime;
if (timer >= waitTime) {
return Status.Success;
}
return Status.Running;
}
} PerformanceThis is a benchmark running 5000 trees. No GC after startup. The tree in the image is the tree used for benchmark. Tested on a Intel Core i7-4790 @ 4 GHz. (Windows) The same benchmark was run on a Linux laptop. Intel i5-6200U @ 2.30 GHz. The "Time ms" was on average 4 ms. LimitationsSince the goal of this project was a lightweight system, a complete, built-in functionality for serialization is not provided. The tree and blackboard structure is saved as an asset, but changing data values will not be persistent between game runs. For example, if you have a blackboard variable ["timer", 0.0f] and during the game run, the value goes up to say 10.0, you would need to save and load that value manually so its persistent between game saves. Old Screenshots and videosVideos:
The IsKeyDown decorator has a lower priority abort type set, so the sub-trees to the right are highlighted since they can be aborted by the decorator. Here the semaphore guards are linked which highlight in orange, you can also see the custom inspector for the guard, making it easy to link other guards together. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论