diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cpp index 0fa6810d2362..c1171b429366 100644 --- a/scene/animation/animation_mixer.cpp +++ b/scene/animation/animation_mixer.cpp @@ -1538,6 +1538,12 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) { Variant value = a->track_get_key_value(i, idx); value = post_process_key_value(a, i, value, t->object_id); Object *t_obj = ObjectDB::get_instance(t->object_id); + // Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string + // otherwise this will start an infinite recursion (see GH-98076). + AnimationPlayer *anim_player = Object::cast_to(t_obj); + if (anim_player && t->subpath.has("current_animation") && String(value).is_empty()) { + continue; + } if (t_obj) { t_obj->set_indexed(t->subpath, value); } @@ -1549,6 +1555,12 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) { Variant value = a->track_get_key_value(i, F); value = post_process_key_value(a, i, value, t->object_id); Object *t_obj = ObjectDB::get_instance(t->object_id); + // Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string + // otherwise this will start an infinite recursion (see GH-98076). + AnimationPlayer *anim_player = Object::cast_to(t_obj); + if (anim_player && t->subpath.has("current_animation") && String(value).is_empty()) { + continue; + } if (t_obj) { t_obj->set_indexed(t->subpath, value); } @@ -1860,6 +1872,12 @@ void AnimationMixer::_blend_apply() { } Object *t_obj = ObjectDB::get_instance(t->object_id); + // Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string + // otherwise this will start an infinite recursion (see GH-98076). + AnimationPlayer *anim_player = Object::cast_to(t_obj); + if (anim_player && t->subpath.has("current_animation") && t->value.is_null()) { + continue; + } if (t_obj) { t_obj->set_indexed(t->subpath, Animation::cast_from_blendwise(t->value, t->init_value.get_type())); }