Description

Context

State Tree Tasks have a configurable default value 'Should State Change on Reselect' which controls whether the task receives a EnterState/ExitState if completion of the current state is followed by the same state being re-selected.

Problem

While setting 'Should State Change on Reselect' to true on a state tree task class does cause EnterState/ExitState to be called, the state of the task is not reset to default. This is confusing behavior as the state is exited and entered, but the task keeps its values from the previous iteration. The task should not behave as persistent when the state is exited and entered.

Steps to Reproduce
  • Create a StateTreeTask blueprint STT_ReproTask:
    • Print messages on "EnterState" and "ExitState" on the corresponding events
    • Add an Integer variable
    • Increment and print it on Tick, and call Finish Task on that Tick
  • Create a State Tree ST_ReproTree:
    • Add a Transition to the Root state, letting it go to itself on tick
    • Add STT_ReproTask to the Root state
  • Make an actor blueprint with a State Tree Component that uses ST_ReproTree and place it in the level
  • Start PIE
  • Observe: The log will spam EnterState > 1/2/3/4> ExitState with the number incrementing
  • Observe: The log should spam EnterState -> 1/1/1/1 -> ExitState repeatedly since the task's values should not persist.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-229895 in the post.

0
Login to Vote

Unresolved
ComponentUE - AI - StateTree
Affects Versions5.4.3
Target Fix5.6
CreatedNov 7, 2024
UpdatedNov 8, 2024
View Jira Issue