State Tree Condition Output

Hello, I’ve tried binding output condition property to state parameter, in test condition all is right, and object is valid. But in child state, task input property that bind to the same state parameter is null. Am I correct in understanding that this is the expected behavior, and the context of conditions is not accessible within tasks?

Has Held Item correctly sets output property, but in drop task CarriedItem parameter is nullptr.

Hey @LordLeks how are you?

First of all, let me clarify I’m not a programmer, so I may be wrong! But I’ve been looking for an explanation and I think you are right, that is the expected behavior. This is because Condition Outputs are evaluated during state selection/transition logic, but they don’t automatically propagate their output values to task parameters in child states.

I found some solutions as well, let me share them with you:

  • Use a shared State Tree parameter: Set the held item directly to a state parameter that both the condition and task can access. You might need a task that runs before “Drop Item” to capture the held item into the parameter.
  • Move the logic into the task’s EnterState: Instead of relying on a condition’s output, have your DropItem task directly query the actor for the held item during its EnterState() function.
  • Use a different binding source: Bind the task’s input directly to the Actor context property if possible, rather than going through the condition output.
  • Create an intermediate task: Add a task between the condition and DropItem that copies the held item reference to a state parameter that DropItem can then use.

I didn’t test those solutions but I think the most straightforward approach would be option 2 or 4, depending on your specific use case, as State Tree conditions are primarily designed for decision-making, not data propagation to tasks.

Let me know if this worked for you!

Hey, thanks for helping. I’ve already solved this issue, just created extra property function.

I realise that its more likely expected behavior. Because enter condition context clear, before executing tasks. Just asking maybe someone checked the source code and confirm it. It’s just my hobby and i don’t have time and skill for checking what inside.

1 Like