- Add a empty UStateTreeComponent on an Actor
- Call SetStateTreeReference on this component by passing a valid FStateTreeReference
- Notice the crash
[Attachment Removed]
Steps to Reproduce
Hello,
For my use case, I would like to use a UStateTreeComponent on my actor that is empty by default and where I can inject dynamically a FStateTreeReference depending of my gameplay context.
Unfortunately I noticed that this is not really intended to use a UStateTreeComponent without linking a UStateTree directly. It generates the following error at InitializeComponent :
“UStateTreeComponent::ValidateStateTreeReference: The State Tree asset is not set.. Cannot initialize.”
Later, when I wanted to use UStateTreeComponent::SetStateTreeReference, it crashed as the method itself does not check if there is a running tree or not before constructing the context. However, the UStateTreeComponent::SetStateTree method actually does this check. It looks like it misses the same check in UStateTreeComponent::SetStateTreeReference.
As a workaround, I added to my UStateTreeComponent a default UStateTree that does nothing and it works fine until I have the following error when setting another tree :
"StateTree runtime check failed: The StateTree ‘%s’ is different from the previously set ‘%s’.
Make sure you initialize FStateTreeExecutionContext with the same value every time.
Auto deactivate Runtime check StateTree.RuntimeValidation.Context to prevent reporting the same error multiple times."
So, first of all, is it really forbidden to use an empty UStateTreeComponent by default, should I always set it a default UStateTree ?
And then, do you know what generates the second error when switching the tree ? I’m using the same Schema and same Context Actor Class on both trees. At the end it’s working fine but I feel that I’m not using it properly, what’s your point ?
Thanks !
[Attachment Removed]
Hi David,
I believe this was addressed in 5.7. You should be able to have a StateTreeComponent without an asset on startup.
SetStateTreeReference does a check for an active StateTree as we do not want to change one currently running, but if the tree is stopped, you should be able to change the StateTree asset. Looking at the runtime validation, there have been several changes lately to better support runtime instance data that may be needed to make this fully work.
-James
[Attachment Removed]