• Đã chỉnh sửa

我使用一個SkeletonGraphic,會根據需求播放A或B兩種動畫
若只播放A的話都沒有問題,在A之後播放B也沒問題
但播過B之後再播放A的話,A動畫中會出現B動畫的內容,看起來就像兩個動畫各自取一部分混在一起
相關部分程式碼如下

[SerializeField] private SkeletonGraphic m_Result;
...
public void PlayAnimation(string animName)
{
    var entry = m_Result.AnimationState.SetAnimation(0, animName, false);
    m_Result.Update(0);
    entry.Complete += (entry) =>
    {
        m_Result.AnimationState.ClearTrack(0);
    };
}

我不確定具體來說是發生了什麼事,請製作該動畫的人員觀察了一下,
他說key frame跟slot中的region沒有依照他的設定呈現
請問要怎麼避免這種現象呢?

  • Misaki đã trả lời bài viết này.
    Related Discussions
    ...

    kaworucloud I guess it is due to the use of CleatTrack(). This method leaves skeletons in their current pose. If you want to return the skeleton to its setup pose after the animation is complete, use SetEmptyAnimation().

    By the way, if the intention is to leave the skeleton in the last pose of the last applied animation, the AnimationState track will leave the last pose as it was without using ClearTrack() at all, so you can simply delete the line calling ClearTrack(). The role of these basic methods may be better understood by watching the following video tutorial:
    https://www.bilibili.com/video/BV1DV4y1A7uf/

    會使用ClearTrack是因為要避免播放時殘留上一次動畫的最後一幀
    如果單純移除ClearTrack,第二次之後播放動畫時,演出似乎會稍微受上一個動畫的影響
    我希望每次播放都是從最初的狀態開始,但又不希望每次都Instantiate一個新物件出來使用

    • Misaki đã trả lời bài viết này.
      • Đã chỉnh sửa

      移除ClearTrack並設定MixDuration為0之後運作正常了

      var entry = m_Result.AnimationState.SetAnimation(0, animName, false);
      entry.MixDuration = 0;
      m_Result.Update(0);
      entry.Complete += (entry) =>
      {
          //m_Result.AnimationState.ClearTrack(0);
      };
      • Misaki đã thích điều này.