How to add Tasks during runtime?

Jyuara

New member
Q1: How to add or insert a Task into existing BehaviorTree?


Q2: When there are more than one [BehaviorTreeReference] tasks, how to assign externalBehavior field to specific [BehaviorTreeReference] via code? Or add a second externalBehavior during runtime?
ex.png

Q3: Is there any API Documentation or ScriptReference ? (more details than the documentation on homepage)

Any advice would be appreciated Thanks!
 
1 & 2: You can use external trees. To add the tree dynamically you can find the Behavior Tree Reference task with BehaviorTree.FindTask and from there assign the externalBehaviors array. In order for the external trees to be reloaded you'll need to restart the tree.

3: I've found that the easiest and most up to date method for the API generation is to just use the Object Browsers built into your IDE. For example, here's how to get to it for Visual Studio: https://docs.microsoft.com/en-us/of...ce/user-interface-help/use-the-object-browser
 
1 & 2: You can use external trees. To add the tree dynamically you can find the Behavior Tree Reference task with BehaviorTree.FindTask and from there assign the externalBehaviors array. In order for the external trees to be reloaded you'll need to restart the tree.

3: I've found that the easiest and most up to date method for the API generation is to just use the Object Browsers built into your IDE. For example, here's how to get to it for Visual Studio: https://docs.microsoft.com/en-us/of...ce/user-interface-help/use-the-object-browser
Thanks for the quick reply. May I ask I should restart the tree by calling which method?Just Disable then Enable?
 
Last edited:
You didn't do anything wrong - that was a bug in BD. What version of Unity are you using? I'll send you a fixed runtime.
 
You didn't do anything wrong - that was a bug in BD. What version of Unity are you using? I'll send you a fixed runtime.
This version works. However this is more likely a replace operation than switch.
1172
My real intention is prepare a switchable node (as placeholder). Then I could switch the externalBehaviors list's children and refresh the whole tree.

So my question is : Could I get the BehaviorTreeReference node back and make it ready for next assign operation? :unsure:
 
When the reference node is replaced it is completely removed from the tree. You could create an external tree with the reference node in it and when you want to switch behaviors you could first switch to that tree.
 
Top