I encountered a similar scenario in my game where I needed to dynamically set the state tree at runtime. My solution was to create a custom class that inherits from UStateTreeComponent
. In this custom class, I implemented a function to replace the current state tree. However, this approach required working in C++, as I couldn’t find a way to inherit StateTreeComponent
directly in Blueprints.
Here’s how I implemented it:
By calling SetStartLogicAutomatically(false)
in the constructor, the state tree does not start automatically, giving me control over when to initiate it.
Here’s an example of how this can be used in Blueprints: