You can`t change frame of animation by codes, try to use tweens:
@export var move_distance := 50 #this is how much it will move, not the position in y
var start_pos
func _ready():
start_pos = global_position.y
var tween = get_tree().create_tween().set_loops()
tween.tween_property(self, "position:y", start_pos+move_distance, 3.0)
tween.tween_property(self, "position:y", start_pos, 3.0)
tween.play()
I agree with KingGD’s solution, but technically you can change frame of animations by code. The downside is that it will also change for your first platform
After create the tween try to use tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS), probably is failing to work because tween by default update in the idle step and physics things should always work on the physics step.
I have this (but with indentation)
func _ready() → void:
# Using tween
start_pos = global_position.y
var tween = get_tree().create_tween().set_loops()
tween.tween_property(self, “position:y”, start_pos+move_distance, speed)
tween.tween_property(self, “position:y”, start_pos, speed)
tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
tween.play()