State trees do not seem to support interfaces. If I try to add a State tree parameter, no interfaces are available as a type in the dropdown. If I try to add variable to an e.g. State tree task implemented by blueprint, I can select interfaces normally.
Example of my interface:
UINTERFACE(NotBlueprintable, BlueprintType)
class UCombatant : public UInterface
{
GENERATED_BODY()
};
class ICombatant
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, NotBlueprintable, Category="Combat")
virtual AActor* GetTarget() const = 0;
};
I tried to override schema methods to specifically allow my type or interfaces in general, but that did not help:
virtual bool IsStructAllowed(const UScriptStruct* InScriptStruct) const override;
virtual bool IsClassAllowed(const UClass* InScriptStruct) const override;
virtual bool IsExternalItemAllowed(const UStruct& InStruct) const override;
In the best case, I would like to add my interface to the schema context. The context variable for Combatant seems to be successfully added, but it doesn’t bind to State tree task context variable:
[Image Removed]
Even if I don’t declare the state tree task variable as context, but as Default and try to bind it manually, there are no candidates for the binding (the dropdown for binding selection doesn’t even open).
The state tree task variable seems to be declared correctly, I can use it within the blueprint implementation as an input to my UFUNCTIONS that accept TScriptInterface<ICombatant>:
[Image Removed]
For completeness, this is how I defined the context variables in the schema:
UCombatRoleStateTreeSchema::UCombatRoleStateTreeSchema()
{
ContextDataDescs.Emplace(CombatantContextName, UCombatant::StaticClass(), FGuid(0x0ca820e8, 0x9a1649c5, 0x8db01c8c, 0xf14165d0));
ContextDataDescs.Emplace(SkirmishContextName, USkirmish::StaticClass(), FGuid(0x41788ddd, 0x52ca4857, 0x8f9255b4, 0x4d81130a));
}
bool UCombatRoleStateTreeSchema::SetContextRequirements(FStateTreeExecutionContext& Context, AAIController& Controller, TScriptInterface<ICombatant> Combatant, USkirmish& Skirmish)
{
if (!Context.GetStateTree()->GetSchema()->IsA(UCombatRoleStateTreeSchema::StaticClass()))
{
return false;
}
Context.SetContextDataByName(CombatantContextName, FStateTreeDataView(Combatant.GetObject()));
Context.SetContextDataByName(SkirmishContextName, FStateTreeDataView(&Skirmish));
return Super::SetContextRequirements(Context, Controller);
}
Since no interfaces are available even as State tree parameters, I suspect that they don’t work in state trees in general, not only in my schema context example. If it is so, is there any reason for that or any plans to support them in future? If they should work, is there anything I’m doing wrong or any workaround I could use?
[Attachment Removed]