Let me first give some information.
Right now, the BehaviourTree’s flow and the Action Tasks are running in paralel. What this means is that when the BehaviourTree is Ticked once, the tree is evaluated. If an Action Tasks is found that needs more than 1 frame to complete, it registers itself in the MonoManager. That action is then updated until it is complete regardless of how often the BT is Ticked. On a later BT Tick, the tree checks the Action’s return status and proceeds accordingly.
This allows for even if a BT is ticked infrequently, that the actions started do update in their own timing.
If Action update was done per Tick of the BehaviourTree, then an action that plays an animation and returns Running until that animation is done, would look stepped if not Ticked constantely, while now a single Tick of the action suffice for it to complete.
On the matter at hand (turn-based), the way I would go about it, would be to set the BehaviourTrees to RunOnce and then call BTO.StartBehaviour(). What this means is that the BT will be evaluated once and keep ticking until it’s root status is either Success or Failure (which means no action is returning Running).
An overload of the StartBehaviour can also take a System.Action callback parameter. This will be called back when the tree is done.
So as a practical example lets take an X-COM style game.
After the player finish his turn, you can call BTO.StartBehaviour(OnFinish), on the first enemy unit.
The unit’s BT can then decide on the unit’s behaviour and then execute this behaviour (PlayAnimations, Movement etc). When the BT is finished, OnFinish will be called where you can pass the turn to another AI unit (by executing it’s own BehaviourTree) or back to the player.
So the BehaviourTree here in essence represents a whole unit’s turn. Decision and execution.
I know you didn’t asked me all this, but I am trying to understand if I am missing something by explaining and suggesting a workflow 🙂
Cheers
Join us on Discord: https://discord.gg/97q2Rjh
Login
Register
By registering on this website you agree to our Privacy Policy.