Skip to content

Commit c637d08

Browse files
committed
Fix #4 : when mutating BTRoot actor_path (from inspector or in script), underlying_actor variable is immediatly updated
1 parent f0459ae commit c637d08

File tree

1 file changed

+8
-4
lines changed
  • addons/yet_another_behavior_tree/src/Nodes

1 file changed

+8
-4
lines changed

addons/yet_another_behavior_tree/src/Nodes/BTRoot.gd

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ signal on_idle()
3030
@export var actor_path:NodePath :
3131
set(value):
3232
actor_path = value
33+
_update_actor_from_path()
3334
update_configuration_warnings()
3435

3536
@export var blackboard:BTBlackboard = null :
@@ -111,13 +112,16 @@ func _check_direct_children_validity() -> bool:
111112
func _check_actor_validity() -> bool:
112113
var is_valid:bool = actor_path != null and not actor_path.is_empty()
113114
if is_valid:
114-
_actor = get_node_or_null(actor_path)
115-
if not is_instance_valid(_actor) and is_inside_tree():
116-
# Fallback : si le chemin donné n'était pas relatif à la scene courante, on le check en absolu
117-
_actor = get_tree().current_scene.get_node_or_null(actor_path)
115+
_update_actor_from_path()
118116
is_valid =_actor != null and is_instance_valid(_actor)
119117
return is_valid
120118

119+
func _update_actor_from_path() -> void:
120+
_actor = get_node_or_null(actor_path)
121+
if not is_instance_valid(_actor) and is_inside_tree():
122+
# Fallback : si le chemin donné n'était pas relatif à la scene courante, on le check en absolu
123+
_actor = get_tree().current_scene.get_node_or_null(actor_path)
124+
121125
func _do_execute(delta:float):
122126
_register_execution_start()
123127
_blackboard.set_data("delta", delta)

0 commit comments

Comments
 (0)