I have a sequential gun firing animation that plays correctly in Spine.
But in Unity this animation plays incorrectly once - There are no frame of fire when the gun shot.

If the playback is looped, then all the frames of the animation are played back.... But this is a problem. I need this animation to play once.
How can i fix it?

youtube

@VOXELIUM Changing the animation via the Inspector property Animation Name while in Play mode is not intended for precise playback changes, just for simple previews. In-game you will set your animation via the AnimationState API, like skeletonAnimation.AnimationState.SetAnimation(), as shown in all example scenes and in the documentation. Did you encounter problems with this as well?

  • VOXELIUM がこの投稿に返信しました。

    Harald
    I haven't done this yet, but I noticed that all the frames were playing when I reduced the animation speed.

    I'll try to play animation through the code and write the result.
    Thank you.

    Harald


    for test I tried making shots on a timer. All subsequent shots are played correctly but the first animation is incorrect. Notice the moment when I enable Play in Unity

    @VOXELIUM Sorry to hear your problem persists. Which version of the spine-unity runtime (name of the unitypackage, also listed in Assets/Spine/version.txt, or alternatively in the Unity Package Manager window) are you using? If you aren't using the latest version from the download page, please try whether the issue persists with the latest version (backup your project first before any updates).

    If the problem persists with the latest spine-unity runtime:
    Could you please send us your problematic exported assets (the three files)? You can attach them as a zip package to a posting here, or send them via email to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context.

    • VOXELIUM がこの投稿に返信しました。

      Harald I updated to spine-unity-4.1-2023-11-28 and it got even worse. Now, between shots the weapon shakes.
      I prepared this scene for you and sent it to email contact@esotericsoftware.com

      @VOXELIUM Thanks for sending the reproduction project.

      You seem to have misunderstood how AnimationState.SetAnimation() works. You are calling it every frame with the same animation, which re-starts it over and over again. SetAnimation() is intended to be called once for each animation change.

      Changing your code to the following resolved any issues and plays back the animation normally:

          IEnumerator Start()
          {
              yield return new WaitForSeconds(1.0f);
              GunShot();
          }

      Having stumbled upon it, you can also simplify the following code from

      if (ON == true)
      {
          ON = false;
      }
      else
          ON = true;

      to

      ON = !ON;

      In general it's highly recommended to get familiar with the spine-unity runtime first by following the examples. Be sure to check out the example scenes in Spine Examples/Getting Started that come with the spine-unity runtime. There is also a documentation section about it including a video.

      In general the following documentation pages should be helpful as a first point of reference in case of any problems:
      https://esotericsoftware.com/spine-unity#FAQ
      https://esotericsoftware.com/spine-unity
      https://esotericsoftware.com/spine-api-reference

      • VOXELIUM がこの投稿に返信しました。