Transition behaviours of AnimationStateMachineNode nested in AnimationTransitionNode

Godot Version

$ godot-mono --version
4.6.1.stable.mono.arch_linux.14d19694e

Question

I’m making a 3d character controller, with animation clips for idle/walk_start/walk/walk_stop.

For flexibility, in the AnimationTree, the output is connected to an AnimationNodeTransition with inputs for Move and Idle. The Move node is a AnimationNodeStateMachine (state_machine_type = root) of: Start → walkfwd_start → walkfwd → walkfwd_stop → End.

See picture of AnimationTree:



I use a simple statemachine in c# for controlling the character, and I only put animation related part here:

class MoveState : State
{
    // this is the AnimationTree Node, defined in the base class, State
    // [Export] private _animator
    public override void Enter()
    {
        _animator.Set("parameters/Base/transition_request", "Move");
    }
    public override void Exit()
    {
        // _playback is the AnimationNodeStatemachinePlayback
        _playback.Travel("Animacer_WalkFwdStop_LU");
        // FIX: if use Travel here, there will be no transition
        // the animation will directly jump from walkfwd_looping to idle
        // cannot see the walkstop animation
        // no matter whether _animator.Next() follows
        // FIX: if use Start here, walkloop -> walk_stop won't have transition, 
        // but walk_stop -> idle will have a good transition
    }
}
class IdleState: State
{
    public override void Enter()
    {
        _animator.Set("parameters/Base/transition_request", "Idle");
    }
}

// ...
// change state is defined in statemachine,
// called in the input handling callback of state
    public void ChangeState<T>() where T : State
    {
        Current.Exit();
        if (!States.ContainsKey(typeof(T)))
            throw new System.Exception($"StateMachine {this} doesn't contain a {typeof(T)} State!");
        Current = States[typeof(T)];
        Current.Enter();
    }

Now, the problem is, in the Exit() of MoveState:

    public override void Exit()
    {
        // _playback is the AnimationNodeStatemachinePlayback
        _playback.Travel("Animacer_WalkFwdStop_LU");
        // FIX: if use Travel here, there will be no transition
        // the animation will directly jump from walkfwd_looping to idle
        // cannot see the walkstop animation
        // no matter whether _animator.Next() follows
        // FIX: if use Start here, walkloop -> walk_stop won't have transition, 
        // but walk_stop -> idle will have a good transition
    }

What I am expecting is something like

walk_loop
    | transition of AnimationNodeStateMachine
    --------> walk_stop
         | transition of AnimationNodeTransition
         ---------> idle

Or is there any other solutions? thx in advance.

tl,dr:
With the animationTree same with above, when I want to stop, I do:

_playback.Travel("Animacer_WalkFwdStop_LU");
_animationTree.Set("parameters/Base/transition_request", "Idle");

But there is no transition. How to modify this?

First Travel, then wait for the AnimationStarted event, then transit. Like:

public override void HandleInput(InputEvent @event) {
    // when stop input
    _animator.AnimationStarted += UnsubscribeAndToIdle;
    _playback.Travel("FwdStop_LU");
}
private void UnsubscribeAndToIdle(StringName s)
{
    _animator.AnimationStarted -= UnsubscribeAndToIdle;
    _stateMachine.ChangeState<UnitIdleState>();
}

solves this.