State Tree Delay Task not working

Hello, I’ve recently started messing around with State Trees, I was trying to implement a common example I’ve done many times with BTs which consists in:

  • Agent Finds random position
  • Agent moves to the found position
  • Agent Waits X seconds

However I’ve come across two different situations in State Trees where the placement of the “Wait State” that runs the “Delay Task” seems to change the execution of the delay task.

In the following image, the behavior works as expected, the agent waits, finds a position and moves to that position.

However, if I place the “Wait Delay” state, below the “Find Position” state, which contains a task, it no longer works.
image

I created my own Wait task to see what was happening, my task blueprint simply executed a delay node. I replaced the default Delay Task with my custom one, but the behavior remained was the same.

When the “Wait Delay” was placed below the “Find Position” State, it would just spam the output log with the first print on my custom task, never actually finishing the delay and breaking the State Tree.

I’ve read the State Tree Overview Documentation many times at this point and didn’t read anything that would cause this issue.
The documentation actually shows a similar setup with smart objects, and explains the following:
" StateTree comes with the Next Transition, which simplifies creating and arranging a sequence of States.

In the example above, when the Reach State is selected, the Find SO Target, Move to SO, and Look Tasks are executed. Once the Tasks are completed, the Next Transition moves execution to the Use State below, where its Tasks can begin executing."

So I guess my question is, is this Intended? Have I encountered a bug? I’m failing to understand why this could be the intended behavior, any insight would be appreciated.

1 Like

I’m having Verbatim the exact issue and it happens when you try to use ‘Try Enter’ to force a Parent State to Run a Task…this inevitably forces you to also specifically tell it where you want to transition…which seems to be completely breaking the State Tree. I reported this as a bug and I hope to get some answer…I would really like to see staff respond to this…

I thought I would inform you that I did find a way around this but it requires you to not run tasks and try enter states with children. I’m not sure if that is supposed to be a feature or if it’s just that people are misunderstanding State Trees and doing it like that but it doesn’t seem to be a safe way to set things up.

Btw I did run this in a Source Build of UE5.4 and it did the same thing so I think it may be safe to assume this will still be a problem when 5.4 is officially released.

So, this is what I think is happening.

I have recreated the setup you have with a short task (called Shortus), a long task (called Longus) and a very short task (called Cat). Don’t judge me please. :stuck_out_tongue:

st v1

  • State Selection is happening
    • Selector states (states with children or “leaf states”) cant be selected directly
    • Leaf 1 can be selected, so it is selected
  • Active states: Leaf 1 and Selector
  • ALL tasks of Leaf 1 and Selector start running concurrently
  • Cat task is very quick, Longus takes a while.
  • When Cat finishes, the transition is triggered. The transition for Cat is to go to Leaf 1
  • For SOME reason Cat is not run again, but keeps triggering the transition to Leaf 1 over and over again

You can “solve” this by not executinga Finish Task Node on Cat. Then the the Leaf 1 is run, then Leaf 2, and it repeats the tree, but for some reason never runs Cat again.

If you instead remove the transition from the Selector, it will start Cat over and over again.

Yeah, I tried to figure it out for like an hour now, with no success.