From 2cb1c51038e6de1c980532f335a5a0a9abcdb3a8 Mon Sep 17 00:00:00 2001 From: Seif El-Din Ahmed Date: Thu, 2 Oct 2025 22:57:19 +0300 Subject: [PATCH] Expose is_valid() --- doc/classes/AnimationPlayer.xml | 11 +++++++++++ scene/animation/animation_player.cpp | 1 + 2 files changed, 12 insertions(+) diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index 7490833ec65..62a43e6c6bf 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -93,6 +93,17 @@ Returns [code]true[/code] if an animation is currently playing with a section. + + + + Returns [code]true[/code] if the an animation is currently active. An animation is active if it was played by calling [method play] and was not finished yet, or was stopped by calling [method stop]. + This can be used to check whether an animation is currently paused or stopped. + [codeblock] + var is_paused = not is_playing() and is_animation_active() + var is_stopped = not is_playing() and not is_animation_active() + [/codeblock] + + diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 8f20dd5e47f..fb012f4cd6c 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -977,6 +977,7 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("pause"), &AnimationPlayer::pause); ClassDB::bind_method(D_METHOD("stop", "keep_state"), &AnimationPlayer::stop, DEFVAL(false)); ClassDB::bind_method(D_METHOD("is_playing"), &AnimationPlayer::is_playing); + ClassDB::bind_method(D_METHOD("is_animation_active"), &AnimationPlayer::is_valid); ClassDB::bind_method(D_METHOD("set_current_animation", "animation"), &AnimationPlayer::set_current_animation); ClassDB::bind_method(D_METHOD("get_current_animation"), &AnimationPlayer::get_current_animation);