AnimationPlayer Node, setting animation to a specific frame/time via code

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

Basically I have a health bar that is animated using the animationPlayer node and I want to jump to a specific frame to represent the players health.

I can’t seem to figure out how to set an animation to a specific frame/time.

:bust_in_silhouette: Reply From: newold

i found this in documentation:

void seek ( float seconds, bool update=false )
Seek the animation to the seconds point in time (in seconds). If update is true, the animation updates too, otherwise it updates at process time. Events between the current frame and seconds are skipped.

$animationPlaye.seek(0.05, true) # show current animation on frame time 0.05

LOL I swear I tried that earlier but couldn’t get it to work. Anyway thank you so much, I managed to get it to work now.

Arkinum | 2019-07-13 20:57

thanks that helped me out.

morningkingdom | 2022-11-30 16:50