X Tutup
Skip to content

Fix Animation Editor erroring when animating SpriteAnimation3D frame but not animation.#113786

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
kmMuellerGit:202512_sprite_animation_check_if_animation_key_exists
Jan 7, 2026
Merged

Fix Animation Editor erroring when animating SpriteAnimation3D frame but not animation.#113786
Repiteo merged 1 commit intogodotengine:masterfrom
kmMuellerGit:202512_sprite_animation_check_if_animation_key_exists

Conversation

@kmMuellerGit
Copy link

Fixes 113715

The animation editor no longer directly accesses the 'animation' track for AnimatedSprite2D&3D and instead checks if it first exists and if any key value was found.
Previously this would generate errors in the editor.

With the changes the editor remains responsive in the following two cases, when previously it would generate errors.

  1. Without an animation track each frame-key displays a diamond.
image
  1. With an animation track, each frame-key displays the frame from the animation. If no animation key has been set yet (first diamond) or frame index does not exist in the animation (second diamond) a diamond is rendered.
image

[TokageItLab comment] recommended two items.

  • If animation track is not accessible, do not try to find the sprite's current animation. This has been followed.
  • Add a warning. On this I'd like a second opinion on if we should emit a warning when a SpriteAnimation2D&3D do not have an animation track set or a value is not available from it.

Finally this is my first merge request here - learning along the way :)

@kmMuellerGit kmMuellerGit requested a review from a team as a code owner December 9, 2025 04:27
@AThousandShips AThousandShips added bug topic:animation topic:editor cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release labels Dec 9, 2025
@AThousandShips AThousandShips added this to the 4.6 milestone Dec 9, 2025
Copy link
Member

@TokageItLab TokageItLab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a warning would be possible, but it's sufficient to avoid errors. It would probably be better to get a more review by @dalexeev @Mickeon @KoBeWi

Comment on lines +430 to +432
if (!animation_name.is_empty()) {
texture = sf->get_frame_texture(animation_name, frame);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!animation_name.is_empty()) {
texture = sf->get_frame_texture(animation_name, frame);
}
if (!animation_name.is_empty()) {
texture = sf->get_frame_texture(animation_name, frame);
} else {
WARN_PRINT_ONCE("SpriteFrames: " + String(sf) + " animation can't be determined since it is changed depend on the runtime state.");
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of printing, it should be shown somewhere in the editor (like a warning icon next to the track), but it's not worth it.

Note that WARN_PRINT_ONCE is literally printed once. Users would end up with some random warnings with vague explanation (the message does not really indicate that the warning comes from the editor).

@KoBeWi
Copy link
Member

KoBeWi commented Dec 12, 2025

I don't think adding a warning is useful. If no preview is available, falling back to generic key icon is fine.

tbh I was not even aware that AnimationPlayer has such elaborate logic for AnimatedSprite previews. Why would you even need that if AnimatedSprite has built-in animation capabilities? 🤷‍♂️

@TokageItLab
Copy link
Member

The AnimatedSprite having two playback methods is a feature that's been in place for a long time (3.0 or older?), and this preview has existed since then. However since it's at least only an Editor-side process and doesn't affect runtime, so I think it's not a bad thing to keep it.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to approve earlier.

@Repiteo Repiteo merged commit 5d9722e into godotengine:master Jan 7, 2026
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jan 7, 2026

Thanks! Congratulations on your first merged contribution! 🎉

@akien-mga
Copy link
Member

Cherry-picked for 4.5.2.

@akien-mga akien-mga removed the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Jan 16, 2026
@akien-mga akien-mga changed the title Fix Animation Editor erroring when animating SpriteAnimation3D 'frame' but not 'animation'. Fix Animation Editor erroring when animating SpriteAnimation3D frame but not animation. Jan 25, 2026
rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
…_animation_check_if_animation_key_exists

Fix Animation Editor erroring when animating SpriteAnimation3D 'frame' but not 'animation'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnimationPlayer with SpriteFrames3D errors when using 'frame' as animated value

6 participants

X Tutup