For a turn-base game, I would suggest to first and foremost, disable the “Repeat” option found in the BehaviourTreeOwner inspector, since there is not really a need to repeat the behaviour, but rather only tell it to execute (plan + action) when the AI turn is at hand.
With the “Repeat” option disabled, the BehaviourTree will run up until a Success or Failure Status is returned (to the root) and then stop. As such, even with “Repeat” disabled, the BehaviourTree can both include planning (1 frame actions) as well as action (possibly multime frames Running actions).
By having the “Repeat” option disabled though, it means that you will have to manually call “BehaviourTreeOwner.StartBehaviour()” whenever the AI needs to make a decision (as well as execute it).
Regarding debuging the tree in cases where it takes only 1 frame to complete, I have tried in the past to make the Status colors/icons have a delay and be rendered multiple frames in the editor, but it turned out that it was very confusing since it wasn’t always illustrating the current status of the node but rather a previous status with latency. As such and in those cases, I would like to suggest to use Breakpoints where adequete. Using breakpoints will also pause the Unity editor, where you will then be able to “step” through the frames using the usual Unity button next to the Play button. By doing this, you will be able to also see the color/icons status of the nodes after each step.
Once again though, I will suggest to try disabling “Repeat” for a turn-based game and manually calling StartBehaviour() whenever the AI needs to plan and act, as described above.
Please let me know what you think.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.