How to Change Animation Before a Specific Frame Starts in AnimatedSprite2D?

Godot Version

4.2

Question

Hello!

Is it possible to change the animation before a frame starts with AnimatedSprite2D?

For example, my “walking” animation has 8 frames, and the “running” animation has 20 frames. I need the player to switch from “walking” to “running” at a certain speed, but I need this to happen only after frame 3 finishes and before frame 4 starts. It would be like the third frame completes its time and then switches to another animation.

I tried using the frame_progress property, but it returns the percentage of time elapsed in the frame, which could jump from 80% of frame 3 to 15% of frame 4, so I wouldn’t know exactly when the frame ends. I also tried using the frame_changed signal, but it didn’t work because the signal is triggered after the frame is rendered, so frame 4 would appear.

Any help is welcome!

Thank you!