Tweening until button is pressed

Godot Version

Godot 4.3

Question


Hi everyone, I have a question regarding Tweens. For my game as seen above, I need the arrow to go up and down infinitely until the player presses a button, in which it will stop at its current location and determine which color rarity it ended on.

After doing some coding I was able to get the Tween to work, kind of:


My issue is how can I run these two lines infinitely until the player presses a button, in which it stops at its current location? How can I maintain the loop while tracking for input at the same time? Thanks

You can use the Tween.set_loops() function to make the loop go on indefinitely. Then you call Tween.kill() when the button is pressed. Make sure to keep a reference to the tween so you can kill it at that point.

2 Likes

Thanks

1 Like