mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-28 11:27:24 +08:00
``` The following 25 packages will be updated: Package Name Current Version Updated Version Update Reason flame 1.32.0 1.33.0 manual versioning flame_test 2.0.3 2.1.0 manual versioning flame_audio 2.11.10 2.11.11 updated with patch changes flame_behaviors 1.2.0 1.3.0 updated with minor changes flame_console 0.1.2+12 0.1.2+13 updated with patch changes flame_fire_atlas 1.8.11 1.8.12 updated with patch changes flame_network_assets 0.3.3+16 0.3.3+17 updated with patch changes flame_spine 0.2.2+16 0.2.2+17 updated with patch changes flame_sprite_fusion 0.2.0+3 0.2.1 updated with minor changes flame_steering_behaviors 0.2.0 0.2.1 updated with minor changes flame_tiled 3.0.7 3.0.8 updated with patch changes flame_behavior_tree 0.1.3+16 0.1.3+17 dependency was updated flame_oxygen 0.2.3+16 0.2.3+17 dependency was updated flame_isolate 0.6.2+16 0.6.2+17 dependency was updated flame_texturepacker 5.0.1 5.0.2 dependency was updated flame_bloc 1.12.17 1.12.18 dependency was updated flame_kenney_xml 0.1.1+16 0.1.1+17 dependency was updated flame_lottie 0.4.2+16 0.4.2+17 dependency was updated flame_markdown 0.2.4+9 0.2.4+10 dependency was updated flame_rive 1.10.19 1.10.20 dependency was updated flame_forge2d 0.19.2 0.19.2+1 dependency was updated flame_noise 0.3.2+16 0.3.2+17 dependency was updated flame_riverpod 5.4.19 5.4.20 dependency was updated flame_svg 1.11.16 1.11.17 dependency was updated flame_3d 0.1.1+2 0.1.1+3 dependency was updated ```
This is a bridge package that integrates the behavior_tree dart package with Flame engine.
Features
This package provides a HasBehaviorTree mixin for Flame Components. It can be added to any
Component and it takes care of ticking the behavior tree along with the component's update.
Getting started
Add this package to your Flutter project using:
flutter pub add flame_behavior_tree
Usage
-
Add the
HasBehaviorTreemixin to the component that wants to follow a certain AI behavior.class MyComponent extends Position with HasBehaviorTree { } -
Set-up a behavior tree and set its root as the
treeRootof theHasBehaviorTree.
class MyComponent extends PositionComponent with HasBehaviorTree {
Future<void> onLoad() async {
treeRoot = Selector(
children: [
Sequence(children: [task1, condition, task2]),
Sequence(...),
]
);
super.onLoad();
}
}
- Increase the
tickIntervalto make the tree tick less frequently.
class MyComponent extends PositionComponent with HasBehaviorTree {
Future<void> onLoad() async {
treeRoot = Selector(...);
tickInterval = 4;
super.onLoad();
}
}
Additional information
When working with behavior trees, keep in mind that
- nodes of a behavior tree do not necessarily update on every frame.
- avoid storing data in nodes as much as possible because it can go out of sync with rest of the game as nodes are not ticked on every frame.