-
-
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
Method at time 0 in animation gets called repeatedly if paused and resumed #85950
Comments
It is intended behavior that this triggers an infinite loop as we can see it in the code. The fact that it was only processed twice before 4.1 is in some ways not the correct behavior, but it may be due to differences in the timing of the application of delta between 4.1 and 4.2. |
Sorry don't understand, how is this intended behavior? There should be no infinite loop from the code here, I expect the call method to only be triggered once, as I'm not rewinding or restarting the animation. And furthermore, it's an inconsistency that this only happens if the method is at time zero. |
Does pausing work differently on the first frame? Does it normally play the next frame after calling |
No, your method call play(), it means restart. The code is apparently calling stop and play repeatedly on the same time. |
|
Since there is a method key in the play() position, it is fired, the method is called again, and the frame is processed indefinitely. I don't know what you are trying to do, but a straightforward way would be to return the method early by flagging it. |
If that's by design, then there are two problems:
|
No. If there is a key there at playback time, the method must be played. Your mistake is that you are doing stop and play in the same method.
Your method triggers an infinite loop even if time is not 0. |
According to what? The design? The AnimationPlayer code? Not sure what you mean exactly.
It doesn't for me, did you run the project? If you can't reproduce on your end, perhaps it depends on the machine. |
It is an affordance rather than a design; there are tons of use cases that put method keys on 0 of the timeline, which need to be fired by play(). I have seen several use cases where one can move to another animation in a method key or seek to another time in the same animation, such as in an A-B loop. However, play() of the same animation at the same current time, as you do, is an abnormal use case, as it obviously leads to an infinite loop.
I do not know why you cannot reproduce, I think everyone can reproduce it with the MRP. Maybe you are using a different project. |
Sure, and that can be accomplished with
Well, I'd say it wasn't at all obvious, or I wouldn't have opened this issue :) haha.
Huh, interesting. I'm using the same MRP, in Godot 4.2 2023-12-09.17-06-42.mov |
4.2 has a bug where the key retrieval is not accurate, so 4.2.1 must be used. |
It is obvious from the programmer's point of view that when there is a key at the 1s point, when you stop at the 1-second point and play at the 1s point, it is natural to continue processing the same key. As commented above, straightforward workaround is add a flag to avoid infinity loop. In conclusion, this is the intended behavior. If I had to say so, it is a documentation issue. However, in case such a use case is absolutely necessary, you can send a proposal for an option that |
I'll be making a proposal for sure, thanks for the info! |
#86227 should solve this problem as far as the key position is not The reason this problem occurs especially at var current_delta = 0
func _process(delta):
current_delta = delta
func test():
$AnimationPlayer.pause()
prints("calling the method")
$AnimationPlayer.advance(current_delta)
$AnimationPlayer.play() Also, if you put the method key at extends Node2D
func _ready():
$AnimationPlayer.seek(0.5, true)
$AnimationPlayer.pause()
func test():
$AnimationPlayer.pause()
prints("calling the method")
$AnimationPlayer.play() |
Tested versions
System information
macOS Ventura
Issue description
I'm using AnimationPlayer for cutscenes, some of which have dialogue. I do this with a method track function that pauses the animation, waits for the dialogue to finish, and then resumes the animation:
Note that the
play()
function here is resuming the animation, not restarting it.This is mostly working - the function gets called once, then the animation resumes. The one exception is when the method is called exactly at time 0 in the animation. In this case:
in 4.1.2 / 4.1.3, the method gets called twice, then animation finishes.
in 4.2 stable / 4.2.1 RC1, the method keeps getting called repeatedly, animation never finishes.
Steps to reproduce
run MRP scene, animation will autostart. observe "calling the method" printed two or infinite times
Minimal reproduction project (MRP)
AnimationPlayerIssue.zip
The text was updated successfully, but these errors were encountered: