![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Eclair |
The following code is the code I’m trying to animate GUI.
func play_anim():
$MyControl.visible = true # The last frame is displayed...
$MyControl/MyAnimationPlayer.play("MyAnim")
When this function is executed for the second time or later, the last frame can be seen.
When the animation finishes, the seek may be the last frame.
I am in trouble if I can not see the first frame.
So I tried the following.↓
func play_anim():
$MyControl.visible = true
$MyControl/MyAnimationPlayer.seek(0, true) # red error
$MyControl/MyAnimationPlayer.play("MyAnim")
This code does not stop but a red error appears.
error:
Condition'!Playback.current.from'is true.
How can I return an AnimationPlayer seek to the beginning without an error?
Which version are you using? Godot 3.0.6 or 3.1 beta8?
Zylann | 2019-02-28 13:45
Thank you for your comment, Zylann.
I am sorry that there are incompleteness.
I am using “Godot Engine v3.1.beta5.official”.
Eclair | 2019-02-28 18:56
I tested your code in a simple project and I get the error only once. It happens because before the first call to play()
, there is no current animation, so seek
has nothing to seek through. Is that the case for you?
Zylann | 2019-02-28 20:09
I do not understand it well, but I think it is probably the case.
I tried the following code with reference to your comment.
func play_anim():
$MyControl.visible = true
$MyControl/MyAnimationPlayer.play("MyAnim")
$MyControl/MyAnimationPlayer.seek(0, true) # no error
By executing seek () after play (), no error occurred.
Thank you for testing the code and thinking together to solve the problem.
Your advice solved the problem.
Thank you so much, Zylann! XD
// ==========================================//
I also tried the following code, but it was not good.
$MyControl/MyAnimationPlayer.seek(0) # bad.
or
$MyControl/MyAnimationPlayer.seek(0, false) # bad.
After the second time, the last frame is displayed so it is not good.
// ==========================================//
Eclair | 2019-02-28 21:30