Head bobbing

I am trying to implement a head bobbing sort of movement when the player is walking in first person. I created a simple “head_bobbing” animation for the camera and my approach would be to run the animation frame by frame (then go back to frame 1) while the player is pressing the walking button (with possibility to speed up the animation based on walking speed). When the button is released, the animation goes from whatever frame it is at to the first frame.

My question is, can this be done using nodes or with scripting? I don’t see any node for setting the frame of an animation but only for starting the entire animation.

Finally, do you thing there’s a better way of doing this? Thanks