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

Advancing to a completed non-looping animation state with reset = false to show last frame does not perform in StateMachine since there is no remain time #83522

Closed
adambiser opened this issue Oct 17, 2023 · 12 comments

Comments

@adambiser
Copy link

Godot version

v4.1.2.stable.official [399c9dc]

System information

Godot v4.1.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GT 730 (NVIDIA; 30.0.14.7414) - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 Threads)

Issue description

I have an AnimationTree state machine with two states: falling and attack. Both are non-looping animations.

What I want to do is have a falling animation where the final key frame values are held until the player hits the ground.
The attack state can interrupt the falling state at any point and after playing completely through (switch mode = At End), returns to the falling animation state where it left off (reset = false).

However, if the falling state has reached its end when the attack state is started, returning to the falling state does not process the final key frame values. I would expect the final key frame state to be set.

Steps to reproduce

  1. Run the attached project.
  2. When the falling animation finishes and top text says to press Space, press Space,
  3. Note that the attack animation is performed.
  4. When the final attack frame displays, note that the text stays the same and does not return to the "falling 2" text despite the fact that the state machine transitions to the "falling" state.

Note: I used a TextEdit control instead of a Label by accident. The behavior is the same though.

Minimal reproduction project

AnimationTreeTest.zip

@TokageItLab TokageItLab added this to the 4.2 milestone Oct 20, 2023
@TokageItLab
Copy link
Member

TokageItLab commented Oct 20, 2023

This is simply because there is nothing left to play there anymore, so there is no transition. I found that there needs to be a case where the transition takes place even though the animation has stopped by MRP.

It is not impossible to implement that behavior and I agree with making it the default behavior, but conversely, is there a case where we do not want to transition? (an option needs to be added) How do you think? @SaracenOne

@SaracenOne
Copy link
Member

SaracenOne commented Oct 28, 2023

I've had a look at this, and I agree, it is very strange and unexpected that the transition occurs but no animation change occurs. At present, I can't think any scenarios where this behaviour might be desirable, but I understand wanting to exercise caution when making a change like this. I'll think about this some more and maybe even take a look at what other engines do in this situation to get some more grounding on what would be considered the most 'correct' behaviour.

Broadly speaking though, a lot of this feeds into the desire I've mentioned of wanting to introduce a more precise and controllable switch type for 4.3 too.

@TokageItLab
Copy link
Member

TokageItLab commented Jan 15, 2024

I thought again about it, but if there is nothing to play there, skipping the transition is most desirable.

However, there is use case where the anyone want to continue to show last frame, so I believe that a correct way would be to implement an option like keep_last_frame that explicitly displays and processes (then, remain time is infinity like looping) the last frame.

For now, a workaround for this is to have a separate animation that loops only the last frame.

@TokageItLab TokageItLab changed the title Advancing to a completed non-looping animation state with reset = false does not perform the final key frame's changes. Advancing to a completed non-looping animation state with reset = false does not perform the final key frame's changes in StateMachine since there is no remain time Jan 15, 2024
@TokageItLab TokageItLab changed the title Advancing to a completed non-looping animation state with reset = false does not perform the final key frame's changes in StateMachine since there is no remain time Advancing to a completed non-looping animation state with reset = false to show last frame does not perform in StateMachine since there is no remain time Jan 15, 2024
@adambiser

This comment was marked as resolved.

@TokageItLab

This comment was marked as resolved.

@adambiser

This comment was marked as resolved.

@TokageItLab

This comment was marked as resolved.

@adambiser

This comment was marked as resolved.

@adambiser

This comment was marked as off-topic.

@TokageItLab

This comment was marked as off-topic.

@adambiser
Copy link
Author

It appears that using Continuous update mode with Nearest interpolation produces the expected behavior and resolves the original "issue". I remember trying this when I first created the issue, but I think it looks correct now.

Thank you for looking into this and the help.

I'm going to close this.

@TokageItLab
Copy link
Member

I suppose you could leave this open for a use case where the remaining time doesn't exist but you want to transition the state to show the last frame (which may not really be your problem), but we may have to write a new proposal for that.

@TokageItLab TokageItLab removed this from the 4.3 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants