From b981d430f1932b2576c309db42be89cc9b8fb3ba Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sat, 31 Aug 2024 19:37:44 +0200 Subject: [PATCH] Fix custom scene root is not used in BTPlayer and BTState --- bt/bt_player.cpp | 2 +- bt/bt_state.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index 75593e9..4457ab4 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -51,7 +51,7 @@ void BTPlayer::_load_tree() { Node *scene_root = scene_root_hint ? scene_root_hint : get_owner(); ERR_FAIL_COND_MSG(scene_root == nullptr, "BTPlayer: Initialization failed - unable to establish scene root. This is likely due to BTPlayer not being owned by a scene node. Check BTPlayer.set_scene_root_hint()."); - bt_instance = behavior_tree->instantiate(agent, blackboard, this); + bt_instance = behavior_tree->instantiate(agent, blackboard, this, scene_root); ERR_FAIL_COND_MSG(bt_instance.is_null(), "BTPlayer: Failed to instantiate behavior tree."); #ifdef DEBUG_ENABLED bt_instance->set_monitor_performance(monitor_performance); diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index 340f6a9..55a760d 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -70,7 +70,7 @@ void BTState::_setup() { ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned."); Node *scene_root = scene_root_hint ? scene_root_hint : get_owner(); ERR_FAIL_NULL_MSG(scene_root, "BTState: Initialization failed - unable to establish scene root. This is likely due to BTState not being owned by a scene node. Check BTState.set_scene_root_hint()."); - bt_instance = behavior_tree->instantiate(get_agent(), get_blackboard(), this); + bt_instance = behavior_tree->instantiate(get_agent(), get_blackboard(), this, scene_root); ERR_FAIL_COND_MSG(bt_instance.is_null(), "BTState: Initialization failed - failed to instantiate behavior tree."); #ifdef DEBUG_ENABLED