diff --git a/addons/behavior_tree/src/behavior_tree.gd b/addons/behavior_tree/src/behavior_tree.gd index 4596866..6f7572b 100644 --- a/addons/behavior_tree/src/behavior_tree.gd +++ b/addons/behavior_tree/src/behavior_tree.gd @@ -21,6 +21,7 @@ onready var bt_root = get_child(0) as BTNode func _ready() -> void: assert(get_child_count() == 1, "A Behavior Tree can only have one entry point.") bt_root.propagate_call("connect", ["abort_tree", self, "abort"]) + blackboard.set_data("behavior_tree", self) start() diff --git a/addons/behavior_tree/src/blackboard.gd b/addons/behavior_tree/src/blackboard.gd index e1acc80..dc7ebe7 100644 --- a/addons/behavior_tree/src/blackboard.gd +++ b/addons/behavior_tree/src/blackboard.gd @@ -14,7 +14,6 @@ extends Node export(Dictionary) var data: Dictionary - func _enter_tree() -> void: data = data.duplicate() diff --git a/addons/behavior_tree/src/btnodes/decorators/bt_repeat_until.gd b/addons/behavior_tree/src/btnodes/decorators/bt_repeat_until.gd index 9757497..6585952 100644 --- a/addons/behavior_tree/src/btnodes/decorators/bt_repeat_until.gd +++ b/addons/behavior_tree/src/btnodes/decorators/bt_repeat_until.gd @@ -19,6 +19,13 @@ func _tick(agent: Node, blackboard: Blackboard) -> bool: if result is GDScriptFunctionState: result = yield(result, "completed") - yield(get_tree().create_timer(frequency, false), "timeout") + if frequency > 0.0: + yield(get_tree().create_timer(frequency, false), "timeout") + else: + var behavior_tree: BehaviorTree = blackboard.get_data("behavior_tree") + if behavior_tree.sync_mode == 0: + yield(get_tree(), "idle_frame") + if behavior_tree.sync_mode == 1: + yield(get_tree(), "physics_frame") return set_state(bt_child.state)