AnimationPlayer - How to Advance to the next keyframe (time) of the same animation?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By arthurZ

Edit: I used the seek method from AnimationPlayer, but it just use the time of the current animation and not the keyframes and I have a lot of animations with different durations. =/


I have an animation with 5 keyframes of 3 second each, and I need that if the CollisionShape2D detects a collision in the third keyframe of the animation it skips to the fourth keyframe, even if it is on time 1.2 second, 2.4 seconds, etc of the third frame.

I need to do this via script using the AnimationPlayer key-frame and not just skipping to the next sprite frame.

Is there anyway to jump to the next key-frame of the current animation? Thanks.