Example of sprite "bobbing" effect with tweens

You can use tweens to make a sprite slowly bob up and down, like it is floating in water. It is a useful effect for powerups and draws the player’s eye to it.

	#sprite slowly moves up and down
	var tween = create_tween().set_loops(INF).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_SINE)
	tween.tween_property($Sprite2D, "position:y", -5, 2)
	tween.tween_property($Sprite2D, "position:y", 5, 2)
1 Like