From dc8f7b4f5dd326ea2f913a0851ccf22fed977100 Mon Sep 17 00:00:00 2001
From: Maybee Rezbit <28355157+SomeRanDev@users.noreply.github.com>
Date: Tue, 26 Aug 2025 07:41:02 -0400
Subject: [PATCH] Expose "fade" methods for AnimationNodeStateMachinePlayback
---
.../AnimationNodeStateMachinePlayback.xml | 24 +++++++++++++++++++
.../animation_state_machine_editor.cpp | 4 ++--
.../animation_node_state_machine.cpp | 8 +++++--
.../animation/animation_node_state_machine.h | 4 ++--
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml
index ba339bb51be..c7087aa76e0 100644
--- a/doc/classes/AnimationNodeStateMachinePlayback.xml
+++ b/doc/classes/AnimationNodeStateMachinePlayback.xml
@@ -40,12 +40,36 @@
Returns the playback position within the current animation state.
+
+
+
+ Returns the playback state length of the node from [method get_fading_from_node]. Returns [code]0[/code] if no animation fade is occurring.
+
+
Returns the starting state of currently fading animation.
+
+
+
+ Returns the playback position of the node from [method get_fading_from_node]. Returns [code]0[/code] if no animation fade is occurring.
+
+
+
+
+
+ Returns the length of the current fade animation. Returns [code]0[/code] if no animation fade is occurring.
+
+
+
+
+
+ Returns the playback position of the current fade animation. Returns [code]0[/code] if no animation fade is occurring.
+
+
diff --git a/editor/animation/animation_state_machine_editor.cpp b/editor/animation/animation_state_machine_editor.cpp
index 6232150940b..133e6a2b01a 100644
--- a/editor/animation/animation_state_machine_editor.cpp
+++ b/editor/animation/animation_state_machine_editor.cpp
@@ -1474,8 +1474,8 @@ void AnimationNodeStateMachineEditor::_notification(int p_what) {
fading_from_node = playback->get_fading_from_node();
current_play_pos = playback->get_current_play_pos();
current_length = playback->get_current_length();
- fade_from_current_play_pos = playback->get_fade_from_play_pos();
- fade_from_length = playback->get_fade_from_length();
+ fade_from_current_play_pos = playback->get_fading_from_play_pos();
+ fade_from_length = playback->get_fading_from_length();
fading_time = playback->get_fading_time();
fading_pos = playback->get_fading_pos();
}
diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp
index f9a70902c5b..e0f437a7ac0 100644
--- a/scene/animation/animation_node_state_machine.cpp
+++ b/scene/animation/animation_node_state_machine.cpp
@@ -334,11 +334,11 @@ float AnimationNodeStateMachinePlayback::get_current_length() const {
return current_nti.length;
}
-float AnimationNodeStateMachinePlayback::get_fade_from_play_pos() const {
+float AnimationNodeStateMachinePlayback::get_fading_from_play_pos() const {
return fadeing_from_nti.position;
}
-float AnimationNodeStateMachinePlayback::get_fade_from_length() const {
+float AnimationNodeStateMachinePlayback::get_fading_from_length() const {
return fadeing_from_nti.length;
}
@@ -1215,6 +1215,10 @@ void AnimationNodeStateMachinePlayback::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_play_position"), &AnimationNodeStateMachinePlayback::get_current_play_pos);
ClassDB::bind_method(D_METHOD("get_current_length"), &AnimationNodeStateMachinePlayback::get_current_length);
ClassDB::bind_method(D_METHOD("get_fading_from_node"), &AnimationNodeStateMachinePlayback::get_fading_from_node);
+ ClassDB::bind_method(D_METHOD("get_fading_from_play_position"), &AnimationNodeStateMachinePlayback::get_fading_from_play_pos);
+ ClassDB::bind_method(D_METHOD("get_fading_from_length"), &AnimationNodeStateMachinePlayback::get_fading_from_length);
+ ClassDB::bind_method(D_METHOD("get_fading_position"), &AnimationNodeStateMachinePlayback::get_fading_pos);
+ ClassDB::bind_method(D_METHOD("get_fading_length"), &AnimationNodeStateMachinePlayback::get_fading_time);
ClassDB::bind_method(D_METHOD("get_travel_path"), &AnimationNodeStateMachinePlayback::_get_travel_path);
ADD_SIGNAL(MethodInfo(SceneStringName(state_started), PropertyInfo(Variant::STRING_NAME, "state")));
diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h
index b7eafafdc9c..ccadbaed2fb 100644
--- a/scene/animation/animation_node_state_machine.h
+++ b/scene/animation/animation_node_state_machine.h
@@ -339,8 +339,8 @@ public:
float get_current_play_pos() const;
float get_current_length() const;
- float get_fade_from_play_pos() const;
- float get_fade_from_length() const;
+ float get_fading_from_play_pos() const;
+ float get_fading_from_length() const;
float get_fading_time() const;
float get_fading_pos() const;