Animation State does not travel at low fps

Godot Version

Godot 4.3

Question

I have a simple 2D setup with animations working fine, however on low-ish FPS values animations stop working properly.

In my _physics_process I use .travel on my AnimationNodeStateMachinePlayback from the AnimationTree to transition between idle/walk animations (.travel("idle") and .travel("walk")). These work fine always. However, I have an attack animation that plays with a timer every 1s and also uses .travel to do the attack animation. This animation stops playing completely at low-ish FPS (~<100) since it’s likely being overridden by the travel calls in _physics_process.

What is the proper way to do this to transition between these animations? I’m assuming I’m either using travel incorrectly or the state machine isn’t setup correctly for what I’m trying to do.

This is the state machine:

This is the relevant excerpt of _physics_process:

    if input_dir:
        velocity.x = input_dir.x * SPEED
        velocity.y = input_dir.y * SPEED
        state_machine.travel("walk")

    else:
        velocity.x = move_toward(velocity.x, 0, FRICTION)
        velocity.y = move_toward(velocity.y, 0, FRICTION)
        state_machine.travel("idle")

and this is the callback for the timer that gets called every second:

func _attack_timer_timeout() -> void:

    _do_attack()


func _do_attack() -> void:

    var closest := attack_area.get_closest_target(global_position)
    if closest == null:
        return

    state_machine.travel("fire") # this seemingly does nothing (unless max_fps is unset)

and my node tree for the character in question:
image

Your state machine nodes aren’t properly connected so when you call the AnimationNodeStateMachinePlayback.travel() method it won’t find a path to travel to and will queue a teleport to the node directly. Because you are traveling to idle or walk (queuing a teleport to them) each physics process, the fire travel is overridden by those sometimes like when the fps are low.

If you want to teleport to the fire node directly without queuing it you’ll need to use AnimationNodeStateMachinePlayback.start() instead.

Yeah, I purposely want the state to teleport, and that context+solution, is exactly what I was looking for. I wasn’t sure about the difference between .start() and .travel(). Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.