Godot Version
4.3
Question
So i want to create a waiting animation for a platform in my game. Pretty simple just some up and down movement, but the tween don’t work correctly.
it should get back to the start position so it’s a loop. But it stopped 0.1 pixels before.
func _ready():
start_position = global_position
waiting_animation()
func waiting_animation():
var random_offset:Vector2 = Vector2(0,randi_range(8,13))
var time:float = 2
if moving_constanty == false and stop_waiting_animation == false:
print("TTTTTTTTTTTTTTTTTTTT")
print(start_position)
print(global_position)
if global_position == start_position:
await get_tree().create_tween().tween_property(self, "global_position",start_position+random_offset,time).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK).finished
await get_tree().create_tween().tween_property(self, "global_position", start_position,time-0.5).set_ease(Tween.EASE_IN).finished
await get_tree().physics_frame
call_deferred("waiting_animation")
elif global_position == end_position:
await get_tree().create_tween().tween_property(self, "position",end_position+random_offset,time).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK).finished
await get_tree().create_tween().tween_property(self, "position", end_position,time-0.5).set_ease(Tween.EASE_IN).finished
await get_tree().physics_frame
call_deferred("waiting_animation")
the outprint is
So it gets called two times. But for some resaon it don’t gets back to starting_position
await get_tree().create_tween().tween_property(self, "global_position", start_position,time-0.5).set_ease(Tween.EASE_IN).finished
await get_tree().physics_frame #i thought maybe it's to close so i added a wait frame
call_deferred("waiting_animation")
What i tried:
different global_position