Fix custom scene root is not used in BTPlayer and BTState

This commit is contained in:
Serhii Snitsaruk 2024-08-31 19:37:44 +02:00
parent f83cf659e8
commit b981d430f1
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
2 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ void BTPlayer::_load_tree() {
Node *scene_root = scene_root_hint ? scene_root_hint : get_owner(); Node *scene_root = scene_root_hint ? scene_root_hint : get_owner();
ERR_FAIL_COND_MSG(scene_root == nullptr, 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()."); "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."); ERR_FAIL_COND_MSG(bt_instance.is_null(), "BTPlayer: Failed to instantiate behavior tree.");
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
bt_instance->set_monitor_performance(monitor_performance); bt_instance->set_monitor_performance(monitor_performance);

View File

@ -70,7 +70,7 @@ void BTState::_setup() {
ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned."); ERR_FAIL_COND_MSG(behavior_tree.is_null(), "BTState: BehaviorTree is not assigned.");
Node *scene_root = scene_root_hint ? scene_root_hint : get_owner(); 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()."); 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."); ERR_FAIL_COND_MSG(bt_instance.is_null(), "BTState: Initialization failed - failed to instantiate behavior tree.");
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED