Godot Version
4.3.1
Question
Hi everyone,
I’m trying to make a simple repeating function using tweens but I keep running into an issue with not being able to start them after they have been stopped.
Here is my function:
var tween = null
func doAnimations(depth):
# move node downwards
node.global_position = node_original_position
var lower_pos = node.global_position - 10
if tween == null:
tween = get_tree().create_tween()
tween.tween_property(node, "position", lower_pos, 3)
tween.tween_callback(doAnimations.bind(depth-1))
if depth <= 0:
tween = null
node.global_position = node_original_position
finishAnimation()
else:
tween.stop()
tween.play()
It creates a tween, moves the node downwards and then recalls the scene with depth-1. Once depth reaches 0, it calls another method, otherwise it restarts the tween.
My issue is that tween.stop() and tween.play() is not working, and the tween is not resetting and playing.
Anyone know what I’m doing wrong?
Thanks