Skip to content

Instantly share code, notes, and snippets.

@anthonyec
Last active July 16, 2023 14:19
Show Gist options
  • Save anthonyec/ba23c921a4dddaaafbb0e08f0385e2ec to your computer and use it in GitHub Desktop.
Save anthonyec/ba23c921a4dddaaafbb0e08f0385e2ec to your computer and use it in GitHub Desktop.
Wait group for Godot
var animations := WaitGroup.new()
for child in get_children():
var tween = child.create_tween()
animations.add()
tween.connect("finished", animations.done)
tween.tween_property(child, "position:x", 10, 1)
await animations.finished
print("All animations finished!")
class_name WaitGroup
extends RefCounted
signal finished
var count: int = 0
func add() -> void:
count += 1
func done() -> void:
count = clamp(count - 1, 0, INF)
if count == 0:
finished.emit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment