Kill subtweens when their parent tween is killed

# Conflicts:
#	scene/animation/tween.h
This commit is contained in:
Malcolm Anderson 2025-07-02 20:49:51 -07:00
parent 8d8041bd4d
commit 9ad608691b
2 changed files with 7 additions and 0 deletions

View file

@ -164,6 +164,7 @@ Ref<SubtweenTweener> Tween::tween_subtween(const Ref<Tween> &p_subtween) {
if (tweener->subtween->parent_tree != nullptr) {
tweener->subtween->parent_tree->remove_tween(tweener->subtween);
}
subtweens.push_back(p_subtween);
append(tweener);
return tweener;
}
@ -200,6 +201,11 @@ void Tween::kill() {
running = false; // For the sake of is_running().
valid = false;
dead = true;
// Kill all subtweens of this tween.
for (Ref<Tween> &st : subtweens) {
st->kill();
}
}
bool Tween::is_running() {