The state tree context defines what data is available from “outside” a StateTree to the states/tasks inside it. In C++, it’s represented by FStateTreeExecutionContext.

The available data in the context typically depends on the type of state tree component you’re using.

Context and AI Controllers

There is special handling for AI Controllers in how the context works.

The base StateTreeComponent populates the context depending on what you set the State Tree Schema’s Context Actor Class to. This is affected by whether the component is owned by a regular actor or an AI controller.

  • If the owner is an AI controller, the context actor will become the AI controller…
  • Unless you change the Context Actor Class to the type of the AI Controller’s pawn class

This means if you want the Actor value in the Context to be the pawn, you must set Context Actor Class to Pawn, or the more specific class your pawn uses. Otherwise the value will always be the AI controller itself.

When using state tree components in non-AI Controller actors, this doesn’t make any difference.

Setting the context actor class values to classes which don’t match the actual classes used may cause the state tree to freeze.