EsotericSoftware / spine-runtimes

2D skeletal animation runtimes for Spine.
http://esotericsoftware.com/
Other
4.42k stars 2.92k forks source link

[godot] The same animation cannot be played back consecutively on the same track in AnimationPlayer #2670

Closed misaki-eymard closed 2 weeks ago

misaki-eymard commented 2 weeks ago

Description: There are times when you want the same animation to run continuously on the same track in AnimationPlayer, not in a loop, but with a slight pause like this: Screenshot 2024-11-06 at 12 07 50 When this is previewed with the play button in the Animation dock, it plays correctly, but when the scene is run, only the first animation plays, and the next animation does not play correctly. Here is a video you can see the problem: https://github.com/user-attachments/assets/9124bce3-7539-4b61-9406-46de5a7ce0b6

Expected behavior: All animations on the same track play correctly, even if the same animation is set consecutively on the same track.

Steps to reproduce:

  1. Download the attached .zip file: The same animation cannot be played back consecutively on the same track in AnimationPlayer.zip
  2. Open the project contained in the unpacked zip with Godot 4.3. (It should open automatically, but if not, open res://Animation-player/animation-player.tscn.)
  3. Select the AnimationPlayer node in the Scene Dock, then select the Test animation in the Animation Dock: Screenshot 2024-11-06 at 12 21 21
  4. Play the animation using the play button, and confirm that the shoot animation plays four times on Track 0 and once on Track
  5. Run the current scene. You can see that after the shoot animation is first played once on track 0, nothing happens for a while, and only after about 3 seconds the shoot animation set on track 1 is played.

The version that can reproduce this issue: Godot 4.3 (Other versions have not yet been tested.)

This issue was reported in the following thread on the forum: https://esotericsoftware.com/forum/d/27217-animationplayer-bug

badlogic commented 2 weeks ago

I can not reproduce this using the latest spine-godot and Godot 4.3, build from source, nor with the latest spine-godot build of 4.3 from our website at https://esotericsoftware.com/spine-godot

https://github.com/user-attachments/assets/b36a3018-eb6d-4958-a989-4037c7f1b11f

badlogic commented 2 weeks ago

Nevermind, I didn't read step 5. Can reproduce. Investigating.

badlogic commented 2 weeks ago

In update_animation_state, we check if the current TrackEntry name is the same as the animation name that was keyed in the Godot AnimationPlayer. If that's the case, we do nothing. This won't work with two keys that key the same animation.

Fix was to switch the AnimationPlayer tracks to discrete update mode, then react to name or loop track changes directly.