Good day everyone,
Just got into StateTrees and I absolutely love it. But I’ve ran into a hiccup where the overridden tick function doesn’t get called.
It derives from UStateTreeTastBlueprintBase and overrides Tick();
Here’s is the tick function code I have added in.
I’ve tried adding in bShouldCallTick = true, and used the FGuardValue_Bitfield(bShouldCallTick , true) Macro as well. But the tick function doesn’t run when state gets entered.
Just before anyone points it out, I have made sure to add the task to the StateTree state.
EnterState & ExitState trigger just fine. It’s only the tick function and I’ve set scheduled tick policy to Allowed.
What am I missing?
Nevermind. I figured it out.
For some reason, deriving from UStateTreeTaskBlueprintBase doesn’t allow the tick function to work.
After referencing the DelayTask for StateTrees, you have to derive from the struct.
FStateTreeTastCommonBase like this:
USTRUCT(meta = (DisplayName = “Stagger Task”)
struct FStaggerStateTreeTask : public FStateTreeTastCommonBase
{
GENERATED_BODY()
using FInstanceDataType = FYourType;
virtual const UStruct* GetInstanceDataType() const override { return FInstanceDataType::StaticStruct(); }
virtual EStateTreeRunStatus EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const override;
virtual EStateTreeRunStatus Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const override;
virtual void ExitState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const override;
}
FYourType is just a plain struct where you add all the fields and variables you want to expose to StateTree editor and Blueprints.
A very roundabout way of doing it, but it’s quite neat after giving this a go.
1 Like