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: