Is there any way to instantiate runtime sub-behaviour tree ?
My case is that I have one big agent behavior tree and part of it is responding for agent role which may change runtime. I couldn`t find any way to instantiate and initialize it at runtime.
Hello,
All sub-behaviour trees used in a parent graph are instantiated automatically.
Do you rather mean a way to activate and deactivate a sub-behaviour tree node?
Can you please explain a bit more.
Let me know, thank you.
Thanks for responding.
My case is that I have defined ScriptableObject which holds behavior tree respond for agent role in the world ( cutting trees, patrolling, etc. ) and I wanna initialize it/plug it into a sub-behavior node in the original root graph.So whole base agent role is included in root graph but the logic response for a role may change at runtime
A solution that I found recently is to attach all available roles behavior trees into list in Blackboard, and then expand behaviour tree property in sub-behaviour node and change it at runtime. Only problem I see with it is that each agent will hold an initialized version of each role in the world. Idk yet if its a big problem in terms of memory etc. but ideally would be to initialize only needed role and if agent will change it then clear old one and initialize new one.
One way to do this is exactly like you mentioned. The “roles” behaviour trees will only initialize once they are used by the “master” behaviour tree (so essentially when you change the blackboard variable holding the graph to a different graph).
The other way of doing what you are after, would be to actually add each “role” behaviour tree as a sub-tree into the “master” behaviour tree and use a “Switcher” node to switch between them (either by an integer or an enum variable on the blackboard). Even with this method, the sub-trees will not be initialized until and if they are actually used, unless the “Pre-Initialize SubGraphs” is checked in the BehaviourTreeOwner, in which case all sub-tree will indeed be pre initialized.
Let me know if that helps. Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.