extends Sprite2D @export var bounce_height: float = 10.0 # How high it bounces in pixels @export var bounce_duration: float = 0.5 # Time for one bounce cycle var tween: Tween var start_position: Vector2 func _ready(): start_position = position start_continuous_bounce() func start_continuous_bounce(): tween = create_tween() tween.set_loops() # Makes it loop infinitely tween.tween_property(self, "position:y", start_position.y - bounce_height, bounce_duration / 2) tween.tween_property(self, "position:y", start_position.y, bounce_duration / 2) func stop_bounce(): if tween: tween.kill() position = start_position