-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating BTSubTree.subtree
at runtime
#94
Comments
subtree
subtree
BTSubTree.subtree
at rutime
BTSubTree.subtree
at rutimeBTSubTree.subtree
at runtime
There was a discussion some time ago: #58 extends BTDecorator
## MyCustomBranch
func _setup() -> void:
var bt: BehaviorTree = load("res://...")
var my_branch: BTTask = bt.instantiate(agent, blackboard)
add_child(my_branch)
func _tick(delta) -> Status:
var child: BTTask = get_child(0)
return child.execute(delta) You may or may not want to isolate the blackboard scope for your subtree like this: var new_scope := Blackboard.new()
new_scope.set_parent(blackboard)
var my_branch: BTTask = bt.instantiate(agent, new_scope) If your branch utilizes blackboard plan system: # Using new scope:
var new_scope: Blackboard = bt.blackboard_plan.create_blackboard(agent)
var my_branch: BTTask = bt.instantiate(agent, new_scope)
# Or not using new scope:
bt.blackboard_plan.populate_blackboard(blackboard, false, agent)
var my_branch: BTTask = bt.instantiate(agent, blackboard) |
Makes sense, thanks for the quick answer. I opened a PR to add a quick mention to this in BTSubtree's doc itself. Feel free to dismiss it if you feel like it's too much detail. |
My tree contains a BTSubTree that I want to load dynamically. In order to do this, I leave the subtree field unset, and a sibling custom node does this:
In the editor, before this runs, I get the following error:
And when my code above runs, the task doesn't update properly.
As a workaround, I tried creating a dummy btree and assign it to the BTSubTree, so that the error isn't raised and the subtree can be replaced. It works until I try to set
subtree
to the new BehaviorTree, which doesn't raise an issue and doesn't update it.Is this supported?
The text was updated successfully, but these errors were encountered: