Modifying StateTree Parameters during Runtime in Unreal Engine 5

Hello Unreal Developer Community,

I am currently developing a game in Unreal Engine 5 where I am leveraging the StateTree system for my player controller logic. I have defined several states in my state tree, including for example a “ComboState” that should, during execution, set a boolean variable LockRotation to true on my player controller. This new feature look pretty awesome and I would like to expand its usage to the global logic of my game and here the player logic.

My primary assumption was that the StateTree system would be able to handle this requirement directly. I’m trying to find a way to modify the parameters of a state tree during its execution. However, the documentation and resources available for the StateTree system, as of now, are not entirely clear on how to achieve this.

I understand from the UE5 source code comments (e.g., the FStateTreeExecutionContext::SetParameters() method) that it should be possible to replace the default values defined in the StateTree asset at runtime. Yet, I am struggling to find concrete examples or a clear path to do this in practice.

A possible workaround could be setting these variables directly on the owner (in this case, the player controller) during the execution of the state. However, I would prefer to utilize the StateTree system to its fullest, and I believe this should be possible to achieve within the system itself.

Could anyone provide a working example or guide me through the process of updating StateTree parameters during runtime? Any help or insight would be greatly appreciated.

Thank you very much in advance for your time and help.

1 Like

Just started using State Trees and am coming to the same conclusion. I’ve also noticed other users asking / saying the same questions. I’ve not learned much but I assumed passing variables back and forth would be more via the tree itself.

In 5.4, we introduced FStateTreePropertyRef which you can use to get a pointer to the data which allows changing the value of the parameter. There are limitations on the types that can work with the property ref and those are found in the StateTreePropertyRef header. This is currently limited to C++, but we are working on some BP support for them in 5.5.

-James

1 Like