I used a behavior tree to create a dialog system in my game. It works very well except I can’t seem to find a way to get the characters to stop repeating their opening dialog once the first Selector’s Child has succeeded. Once any of the dialog branches I highlighted in green finish, it runs the opening exchange (in red) again. Is there a decorator I could use that allows for a “Do Once” type of action where the NPC would stop re-greeting them before giving dialog choices, or is there a better way to structure my behavior tree where the options are presented at a higher priority than the NPCs greeting?
Hello! I think the simplest solution - to add special context variable in your Blackboard. This variable will keep for example tree level (you just need to identify dialog nodes into logical groups). After that let tasks that dont correspond to current value of this variable will return Succeed at once and Sequence can go into further execution… And dont forget - you need to change this variable somewhere in tasks
How would I add a special context variable? Would it be setting a counter via a custom decorator? I’ll experiment with that, but I’m open to suggestions.
You can simply set BB value to value of current task node after it is executed. And check for < when starting executing task nodes. So, at first execution task node will execute fully because BB value < self node value and then set BB value to self node value. At second execution BB value < self node value is false, so task node simply return Succeed