-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Implement AnimationPlayer pause() and resume() #56645
Implement AnimationPlayer pause() and resume() #56645
Conversation
I like splitting stop and play into stop, pause, start, and resume, but this does leave a question. After this change, what will be the best way to replay an animation if it's currently finished, resume an animation if paused, switch to and start an animation if it's not the current one, and do nothing if it's already current and playing? In 3.4's docs, it's unclear to me if var name = "animation_i_want"
if player.assigned_animation != name:
# switch and start
player.start(name)
elif player.is_playing():
# currently playing the anim already, so do nothing
pass
elif player.current_animation_position <= 0:
# stopped, but already on the correct anim, so start it
# but would this even work, or would current_animation_position be null since is_playing() is false?
player.start(name)
else:
# we're not assigned a different anim, not playing, and not at the start, so we must be paused on the correct anim
player.resume() I'm actually having a hard time figuring out how you would do this. There's got to be a better way that I'm missing. |
Note:
is the same as
I would suggest:
|
594f3fc
to
854fe99
Compare
Thanks for the thorough response! That technique you suggest doesn't seem too bad. Would you mind adding info to your docs about what happens if you pause an animation that is already paused or resume one that is already playing, never started, or finished? |
Ensures that play() always plays the specified or current animation from the beginning. Also fixes stop() not resetting the animation.
- Removes play_backwards() - Removes start() from_end parameter. If custom_speed is negative, it will automatically play the animation backwards from the end.
854fe99
to
46f14a9
Compare
Updated the documentation for
and
|
I'd also be interested to hear the response to feedback that "you can now pause any node, so this may be excessive". Specifically, what does this provide that node pausing does not? If the node is paused, does it also freeze animation playback? (Do some forms of pausing cause animations to skip frames?) |
As more of a Godot novice, I would feel like using a generic node-pausing function (that I assume is like turning off processing?) is a hack for pausing an animation. I would expect that to have some sort of consequence besides pausing playback, since I'm not really thinking about pausing the player node so much as the animation it's currently playing. So having a pause method on the player to pause the animation is more reassuring. Plus I'm more likely to find it when looking through the animation player docs wondering how to pause. |
This can simply be addressed in the description section of the node's documentation. |
As for "I would expect that to have some sort of consequence besides pausing playback," if the docs specifically state that it doesn't, would that assuage your concern? Is pausing recursive? |
From the PR description, the original poster probably has some thoughts on that and has thought about it more. But as for myself... I took a quick look at #46191, and it sounds like pausing in that context is basically the same as disabling processing. I didn't see at a glance whether pausing is applied to a single node (and any children, based on their process mode), or if it's global. I guess it must be per-node, otherwise the settings don't make much sense? If the correct way to pause an animation was to stop processing on the AnimationPlayer (via the generic pause functionality), it would definitely have to be documented inside AnimationPlayer. Otherwise, why would one think that the right way to pause playback on an animation was to pause processing of the player and all its children (unless individually set not to inherit)? If the docs specifically state that there aren't any consequences of pausing the AnimationPlayer node aside from pausing playback, and that that's the way you're supposed to do it, that would help my concern. But I do still think the concept of pausing an animation should be separate from pausing gameplay or node processing. It does sound like it's recursive by default, too, and whether that's a bug or a feature for someone who wants to pause an animation will vary. |
We discussed this briefly in a PR review meeting. We want to make sure we get this properly reviewed by all folks currently active on animation APIs (CC @godotengine/animation). There's also a lot of movement around AnimatedSprite right now from @Mickeon @dalexeev, and a lot of conflicting proposals for different parts of the various animation components. I'm generally in favor of this proposal (splitting the current |
Seems like #44345 (comment) is still valid here. |
Thanks for bringing this to my attention. Not a fan of changing |
I am rather in favor of implementing |
I am in favour of adding The last dilemma to figure out for me, and honestly this one surprises me, is the fact that AnimationPlayer's |
I also think that
|
What if we make: 1, 2: It makes more sense to me. |
Partially superseded by #71218. |
Salvage of #44345. #44345 was closed, because it was considered "redundant given #46191 has been merged". However, #46191 does not implement godotengine/godot-proposals#287, fix #27499 or fix #36279. Furthermore, pausing (and unpausing) the entire
SceneTree
is not a convenient or even realistic way of pausing and resuming anAnimationPlayer
's playing animation.As originally identified in #34125 and elaborated on in godotengine/godot-proposals#287, in AnimationPlayer:
Similarly,
AnimationPlayer:stop()
has a parameter that defaults totrue
to either stop and reset the animation or just pause the animation. However, as identified in #27499, althoughstop(true)
resets the playback position it doesn't reset the animation.This PR:
AnimationPlayer
playback_active
property.Closes godotengine/godot-proposals#287
Fixes #27499
Fixes #36279
Supersedes #33733