StateTree subtrees improperly transitioning from completion states in 5.6

In our project, we built several State Tree tasks that could run in parent states and complete immediately following EnterState (for example, setting an AI Character’s movement mode or setting its gameplay focus).

In version 5.5, we made sure those tasks had the option to either return EStateTreeRunStatus::Succeeded or EStateTreeRunStatus::Running once the task was successfully completed. This feature was removed in version 5.6 due to the introduction of a new option to selectively mark which tasks are relevant for state completion.

As we updated our state tree tasks library in 5.6, we modified those tasks to now only return EStateTreeRunStatus::Succeeded, reflecting the new expectation that they could be correctly excluded from the state completion logic.

But, we noticed our State Trees are now skipping leaf states of a subtree if a State Tree task ends in the root state of the said subtree, even when this task is explicitly marked not to be considered for state completion. It doesn’t interrupt the behavior, but once the state completes, it searches for a transition at the parent frame instead of considering transitions from the leaf state. It doesn’t seem to be an issue with Linked Asset, or with regular States.

This issue appears to be linked to the StateTree.GlobalTasksCompleteOwningFrame console variable. Disabling it makes the setup work as intended. This issue seems to be similar to what is discussed in the following forum post: Forum Post

I’ve been able to reproduce the issue in a clean project, using the Third-Person Template. The state tree setup includes every use case I could think of, and highlights an issue with tasks in the root state of a subtree.

You can look in details at the state tree setup in ST_Main, and in the linked asset ST_Linked. (/All/Game/ThirdPerson/Blueprints/StateTree)

ST_Main

[Image Removed]

Notice that the Delay task in the State & Subtree have Toggle Completion set to false.

ST_Linked

[Image Removed]

Notice that the Delay task in the root state has Toggle Completion set to false.

Observations:

At runtime, we should sequentially observe the debug task displayed in the following order:

  1. State - State 1
  2. State - State 2
  3. Subtree - State 1
  4. Subtree - State 2
  5. Linked Asset - State 1
  6. Linked Asset - State 2

But despite the delay task in Subtree being explicitly toggled off for state completion, the execution is blocked, and Subtree >State 2 is never reached. This may be due to the delay task in the Subtree’s root incorrectly considering the transition to Tree Succeeded upon the task completion.

The issue doesn’t appear for similar setup using a Linked Asset, or a similar setup using only regular states.

This issue completly disappears when StateTree.GlobalTasksCompleteOwningFrame is set to false.

Furthermore, with the 5.5 behavior, toggling the delay task’s completion icon on correctly resulted in the state completing immediately upon task completion, whereas toggling it off allowed the leaf states to continue running as intended.

Could you please clarify if this transition behavior in UE 5.6 is by design, or if it constitutes a bug?

[Attachment Removed]

Steps to Reproduce
Everything should already be provided in the repro project attached.

Files created were added under /All/Game/ThirdPerson/Blueprints/StateTree

Steps of reproduction:

  1. Project Setup:
    1. Create a new project using the Third-Person Template.
    2. Under Project>Plugins, enable the Gameplay State Tree plugin and restart the editor.
  2. Linked State Tree Asset Creation
    1. Create a new State Tree asset using the State Tree AI Component Schema and name it ST_Linked.
    2. Add a Delay Task to Root. Crucially, toggle off the completion icon (i.e., do not consider it for state completion) and set the duration to 1.0s.
    3. Add two child states to Root, name them State 1 and State 2, and set their State Type to State.
      1. Add a Delay Task to both State 1 and State 2, setting the duration to 3.0s for both.
      2. Add a Debug Text Task to both State 1 and State 2, setting respectively the texts to “Linked Asset - State 1” and “Linked Asset - State 2”. Bind the Reference Actor to the Context Actor.
      3. Add a transition On State Completed to Next State on State 1
      4. Add a transition On State Completed to Tree Succeeded on Root
    4. Save and close the ST_Test asset.
  3. State Tree Asset Creation:
    1. Create a new State Tree asset using the State Tree AI Component Schema and name it ST_Main.
    2. Add a child state to Root, name it State and set its State Type to State.
      1. Add a Delay Task to State. Crucially, toggle off the completion icon and set the duration to 1.0s.
      2. Add two child states to State, name them State 1 and State 2, and set their State Type to State.
      3. Add a Delay Task to both State 1 and State 2, setting the duration to 3.0s for both.
      4. Add a Debug Text Task to both State 1 and State 2, setting respectively the texts to “State - State 1” and “State - State 2”. Bind the Reference Actor to the Context Actor.
      5. Add a transition On State Completed to Next State on State 1
      6. Add a transition On State Completed to Next State on State
    3. Add a sibling state to State, name it Linked State and set its State Type to Linked.
      1. Add a transition On State Completed to the Next State on LinkedState
    4. Add a sibling state to Linked State, name it Linked Asset and set its State Type to Linked Asset.
      1. Set the linked asset to be ST_Linked, the state tree asset we created in Step 2.
    5. Add a sibling state to the Root, name it Subtree and set its State Type to Subtree.
      1. Add a Delay Task to Subtree . Crucially, toggle off the completion icon and set the duration to 1.0s.
      2. Add two child states to Subtree , name them State 1 and State 2, and set their State Type to State.
        1. Add a Delay Task to both State 1 and State 2, setting the duration to 3.0s for both.
        2. Add a Debug Text Task to both State 1 and State 2, setting respectively the texts to “Subtree - State 1” and “Subtree - State 2”. Bind the Reference Actor to the Context Actor.
        3. Add a transition On State Completed to Next State on State 1
        4. Add a transition On State Completed to Tree Succeeded on Subtree
      3. Set the Linked subtree of Linked State to be Subtree.
    6. Save and close the ST_Main asset.
  4. Setup AI Controller and Character:
    1. Create a child blueprint class of AIController and name it AIC_Test.
      1. Add the State Tree AI Component to AIC_Test.
        1. Assign the ST_Main State Tree to the component’s AI > StateTree property.
      2. Save and close AIC_Test.
    2. Open BP_ThirdPersonCharacter.
      1. Set the AI Controller Class under Pawn to AIC_Test.
    3. Save and close BP_ThirdPersonCharacter.
  5. Run Test:
    1. Open the level Lvl_ThirdPerson.
    2. Drag and drop the BP_ThirdPersonCharacter into the level.
    3. Play the game.

[Attachment Removed]

Hi there,

Thank you very much for your detailed notes & reproduction project/steps.

I was able to reproduce your issue in 5.6 and it definitely seems like a bug. Especially considering that this issue seems to be resolved in 5.7.

Though the change to Global Tasks is an intended change in behavior the issue we are looking at is not. It’s almost as if the execution context is treating the sub-tree as a separate state tree. With the tasks within the root node being global tasks. However that should not be the case. As far as I am aware linked states are just another state. A quick investigation into the unit tests for linked states indicated that should be the case.

I apologize but I so far have not been able to track down the exact CL for the fix itself. Nor have I been able to find anything on the public issue tracker. If it is still an issue and you require the CL for cherry picking I can continue to investigate however it should not be a blocker for you due to the CVar. As the purpose of the CVar is to revert to the old behavior when necessary.

- Louis

[Attachment Removed]