Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godot 4.3.dev4 bug - animation on AnimatedSprite2D not working if frame is present in RESET animation #89163

Closed
ForestGameDev opened this issue Mar 5, 2024 · 8 comments · Fixed by #89389

Comments

@ForestGameDev
Copy link

Tested versions

  • Reproducible in Godot 4.3.dev4.official
  • Not reproducible in Godot 4.3.dev3.official

System information

Godot v4.3.dev4 - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 850M (NVIDIA; 31.0.15.3168) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)

Issue description

AnimatedSprite2D animations not playing based on AnimationPlayer setup.

Consider this setup:

  1. An AnimatedSprite2D called X with a couple of animations that loop.
  2. An AnimationPlayer with animations that only change the "animation" property of X.
  3. An AnimationTree that changes the animations based on a variable that changes based on user input.

I found that, if the AnimationPlayer's "RESET" animation contains the "frame" property of X, then the animations don't play. If you remove the "frame" property then they run fine. Please see the MRP attached.

This used to work in Godot 4.2 and 4.3.dev3, so this is a regression in behavior in 4.3.dev4.

Steps to reproduce

Described above.

Minimal reproduction project (MRP)

BugAnimationPlayer.zip

I included 2 scenes, one where the animations don't play, and one where they play fine. The only difference is one has the "frame" property in the RESET animation, and the other does not.

@ForestGameDev
Copy link
Author

I found that disabling "Deterministic" in the AnimationTree seems to be a workaround. Not sure what side effects it may have.

@Calinou
Copy link
Member

Calinou commented Mar 5, 2024

cc @TokageItLab

@TokageItLab
Copy link
Member

TokageItLab commented Mar 5, 2024

Is it the AnimationPlayer that you want the Animation to eventually play or the AnimationTree?

In 4.3, there are several possible combinations:

  • AnimationPlayer or AniamtionTree
  • Deterministic: true or false
  • CallbackModeDiscrete: Dominant or Recessive or ForceContinuous

If you want to use AnimationTree, setting AnimationTree's CallbackModeDiscrete to Dominant may fix it. AnimationTree in 4.2 behaves as ForceContinuous when at least one track uses Continuous, but behaves as Dominant when all tracks use Discrete. In 4.3, it must be explicitly specified.

The default for CallbackModeDiscrete in AnimationTree is ForceContinuous, which probably should not be changed and should be indicated as a documentation of migration procedure for animation (to be ready by 4.3.stable).

This is because there have been many issues in the past where the int value uses Discrete by default, but when trying to blend it in AnimationTree, it cannot be blended, so in AnimationTree which does blending as main purpose, use ForceContinuous is better as default for many light users who do not know the difference between Discrete and Continuous.

Also if you means you want to play AnimationPlayer, check to see if MRP's AnimationPlayer not playing is simply due to the AnimationTree being Active.

@ForestGameDev
Copy link
Author

Hi, I tested changing CallbackModeDiscrete in the AnimationTree to Dominant, but that didn't work. Disabling Deterministic in the AnimationTree does work.

Based on your comment it seems some changes to help blending animations caused issues for cases like mine where I use an AnimationTree to switch between AnimatedSprite2D animations. I know there's a lot of effort right now in 3D stuff, but I do believe this is a valid use case for 2D games. Please check the example project I uploaded, maybe it's not a valid use case and you could tell me what's the right way to have an AnimationTree to switch between AnimatedSprite2D animations. I still think this should be considered a regression.

@TokageItLab
Copy link
Member

TokageItLab commented Mar 11, 2024

I don't know what state your current project is in, but the case reported as an issue is definitely working correctly with the configuration I described, so this is a documentation issue, not a bug.

stm.mp4

If you have additional information, send a new MRP or test case. Also, not directly related to this issue, but since there was another Discrete related issue (that is regression), check if that solves your problem #89322.

@ForestGameDev
Copy link
Author

Well, your video is showing it not working, I'm expecting the animation to change and also play. Please try out the other scene "scene_correct.tscn". In the video I can see the AnimatedSprite2D animation is changing, but not playing, if you try the other scene you will notice the frames also change.

This is the correct scene:
animation_bug

One animation moves between part of the robot's face, the other moves in the upper margin. My apologies I didn't provide some better animation to make it clear.

So, just to make sure this time is clear let me explain my use case:

In previous versions I was able to have this setup:

  • AnimationSprite with 3 animations, walking, jumping, and attack.
  • AnimationPlayer with 3 animations:
    • walking : just switches the "animation" property in my sprite to the walking sprite animation
    • jumping : just switches the "animation" property in my sprite to the jumping sprite animation
    • attack : this one I animate frame by frame in the AnimationPlayer's animation, so it changes the "animation" property AND the "frame" property. This is because I also enable a hitbox in specific frames.
  • AnimationTree to move between AnimationPlayer animations.

Before, when using walking and jumping, even when I was only switching the "animation" property, the sprite frames were also moving, as the AnimatedSprite2D's animations were always playing. Now, in dev4, the walking and jumping animation only show the first frame of the animation. The "frame" property is in the RESET animation because I use it in the Attack animation, and because of that, it seems the blending is forcing it into the other animations, which was not happening in earlier versions.

@TokageItLab
Copy link
Member

@ForestGameDev It seems that there is no animation in the MPR that contains the margin movement, even if it is scene_currect; you need to check that the MRP in the Description is correct and send a new MRP.

@TokageItLab
Copy link
Member

Ah, I understand that AnimatedSprite will not play unless the scene is run. Yep, something may indeed be odd, so I'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants