How do we avoid animation blueprint warnings when using native transition bindings?

Given the following code :

UCLASS(Blueprintable, hideCategories = AnimInstance, BlueprintType)
class UTestProjectAnimInstance : public UAnimInstance
{
    GENERATED_BODY()

protected:
    UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
    bool TestProp;

public:
    virtual void NativeInitializeAnimation() override;
};

void UTestProjectAnimInstance::NativeInitializeAnimation()
{
    AddNativeTransitionBinding("root", "A", "B",
        FCanTakeTransition::CreateLambda([this]()
    {
        return TestProp;
    }));
}

And the following anim graph :

The graph compiler emits the following warning :

A to B will never be taken, please
connect something to Can Enter
Transition

Looking at the source code, the check in UAnimStateTransitionNode::ValidateNodeDuringCompilation checks for the presence of native bindings, but this is done prior to the invokation of NativeInitializeAnimation, and therefore can never detect the presence of our bindings.

Is there an “earlier” hook we can use to bind our native checks, one that would be run before the call to UAnimStateTransitionNode::ValidateNodeDuringCompilation?

I understand we can put a dummy blueprint transition check in all of our transitions but I would prefer avoiding that.

Hey Luc Tremblay, I just hit the same issue. Did you find a good solution ?

Thanks

I did not, other than commenting out the warning in the source code or using a dummy as you suggested.

FYI since you are also dealing with native code for anim blueprints, the performance of the binding for native callbacks does not scale well at all and becomes unacceptable when you hit a few dozen states and a few dozen native callbacks (in the >3ms on consoles). Luckily it’s rather easy to optimize in the source code or by extending the AnimProxy class BindNativeTransitions method and iterating intelligently instead of naively.

Umm, that is interesting, I actually decided to move a few stuffs from the AnimGraph to native code for performance reason, specifically trying to hit the ‘Fast Path’ in most nodes, including the transitions.

So, based on your profile the expensive thing is the FAnimInstanceProxy::HasNativeTransitionBinding method right ?

Now looking at it make sense what you said, it just linearly iterate through NativeTransitionBindings array which could be a bad idea if the AnimGraph has multiple state machines / states.

Thanks for the advice !

HasNativeTransitionBinding is not that bad, fortunately. It really is the Binding method that is bad, as you noticed.