How to have tween before or after a set loop of tween? For example first tween left to right > then loop up and down 2 times > then tween right to left. Thanks.

Pseudo code:

	# First Tween
	tween.tween_property(body, "position:x", 2, 1)
	
	# Loop this part 2 times
	tween.set_loops(2)
	tween.tween_property(body, "position:y", 2, 1)
	tween.tween_property(body, "position:y", -2, 1)
	
	# Tween this after loop finished
	tween.tween_property(body, "position:x", -2, 1)
  • xyz replied to this.

    xyz
    This doesn't work, first 2 will run parallel.

    	tween.tween_property(body, "position:x", -2, 0.5)
    	tween_1.tween_property(body, "position:y", 2, 0.5)
    	tween_1.tween_property(body, "position:y", -2, 0.5).as_relative()

    This works but feels wrong

    	tween.tween_property(body, "position:x", -2, 0.5)
    	tween_1.tween_property(body, "position:x", -2, 0.5)
    	tween_1.tween_property(body, "position:y", 2, 0.5)
    	tween_1.tween_property(body, "position:y", -2, 0.5).as_relative()
    • xyz replied to this.

      Gowydot You can insert delays into either of tweens to synchronize them using tween_interval(). Look into Tween class reference for details.

        xyz

        I tried what's on the doc before (set_delay(), chain(), stop(), etc..) just to learn what they do. But still not quite right. For example, this will set interval for each tween_1 loop as well. (not what I need)

        	tween.tween_property(enemy_body, "position:x", -2, 0.5)
        	tween_1.tween_interval(1)
        	tween_1.tween_property(enemy_body, "position:y", 2, 0.5)
        	tween_1.tween_property(enemy_body, "position:y", -2, 0.5).as_relative()

        No example of how to do something like this on the doc. It can't be hard or I'm missing something?

        • xyz replied to this.

          Gowydot For your specific case you can put multiple tween_property() calls into a for loop and completely skip using tween's looping system.