Is there a way to use async operations with ordered state selection?
The selection behavior of TrySelectChildren*, TrySelectChildrenWithHighestUtility or TrySelectChildrenAtRandomWeightedByUtility try and select states until the first successful SelectStateInternal.
The downside here is that you can only facilitate failure and continued ordered selection if you have logic that can fail immediately in the same frame. Sometimes a behaviors ability to execute is only truly known after an async operation, such as an EQS query.
Is there a way to facilitate async determination of state execution possibility, that maintains the ordered consideration of the state selection behavior?
So for example if TrySelectChildrenWithHighestUtility has 5 states to consider, but to execute those states, they need to run an EQS query, you don’t really have the ability for all 5 states to be considered in that expected order, because technically you’d need to enter one to begin executing an EQS task within it, and that’s all the selection behavior is really concerned with.
I’d prefer not to be forced to run EQS queries synchronously, so that they can be sure to fail immediately in the FStateTreeTasks_RunEQS::EnterState, so that the selection behavior can continue to execute properly and consider other child states based on the selection mode. It’s not ideal for scalability that async operations are incompatible with the selection modes.
Are there any state tree recommendations for situations like this?
For example sake, consider a subtree like so
- MeleeCombat
- ChargeAbility - needs to run an EQS query
- LungeAbility - needs to run an EQS query
- SpecialAbility1 - executes a GAS ability that does async pre-work
- SpecialAbility2 - executes a GAS ability that does async pre-work
The ideal solution would
- Consider each ability(with associated EQS query), in the order that the selection behavior demands
- Allow the EQS query to run asynchronously
- If the EQS query fails to find a solution, state selection should continue the ordered selection
- Ideally not perform lower priority state EQS queries until it is determined that higher priority ones can’t run(to save processing)
Some possibilities I can think of
- Run the EQS Queries in a global task or evaluator, allowing the child selection behavior to have access to all the potential query results at selection time.
- Pros
- Provides compatibility with child selection
- Cons
- Does a lot more EQS query work than is necessary, simply so that all results are known at state consideration time.
- Inability to use conditions to gate the execution of the eqs, as they would normally be gated through the conditions on the child state.
- The need to constantly run the EQS queries for all potential child states so the results are available within the same substate selection context
- Pros
- Create a custom task/evaluator that encapsulates the ordered and async execution of all the potential sub queries, with
- Pros
- As functional as I need it to be, as a supertask
- Cons
- Completely circumvents the state tree structure means that I’d be giving up conditionals, utility selection
- Less plugin-able than using discrete states(linked assets, etc)
- Pros
I don’t love fighting against the state tree in these ways, so neither of these is super appealing. Is there a way I don’t have to completely abandon or break the state tree structure just to maintain ordered state selection along with async tasks?
Thanks
Jeremy
[Attachment Removed]