Possible bug in StateTree SetLinkedStateTreeOverrides

Hi,

In FStateTreeExecutionContext::SetLinkedStateTreeOverrides, there is this code:

     if (!RootStateTree.HasCompatibleContextData(*ItemStateTree))
      {
        STATETREE_LOG(Error, TEXT("%hs: '%s' using StateTree '%s' trying to set override '%s' but the tree context data is not compatible."),
          __FUNCTION__, *GetNameSafe(&Owner), *GetFullNameSafe(GetStateTree()), *GetFullNameSafe(ItemStateTree));
        bValid = false;
        break;
      }

(StateTreeExecutionContext.cpp~1234 (yes that’s the actual line number lol)) in 5.8.2

This condition appears to be backward: we think it should be:

if (!ItemStateTree->HasCompatibleContextData(RootStateTree))Because we want to allow `ItemStateTree` to have parameters which are subclasses of RootStateTree’s parameters, and not vice versa.

[Attachment Removed]

Steps to Reproduce[Attachment Removed]

This is something we are aware of, and I do believe your change for using !ItemStateTree->HasCompatibleContextData is correct to mirror what is done in SelectStateInternal_LinkedAsset. We have an open issue for this that can be found here: UE-372599

We have looked at looser context data constraints, but our attempts have not satisfied all of our requirements. I will note that StateTree is not seeing much activity at this moment with the focus on UE6, and I do not foresee the looser context data requirments making it into a release for UE5.

-James

[Attachment Removed]

Hey Jeff,

In case you’re interested, I came up with a potential solution to this and similar cases to make overriding State Trees a bit more dynamic. See my response to this thread:

[Adding support for State Tree Linked Asset Overrides when the Overriding State Tree matches the runtime Owner [Content removed]

Note that we’re using 5.6.1 at the moment, so it’s possible you’ll need to make some adjustments for 5.8. Hope this helps!

[Attachment Removed]