• RuntimesUnity
  • SkeletonMecanim in Unity always delay 1 frame on transition

Hi,

I have read SkeletonMecanim script and I wonder why you guys does not expose a ManualUpdate to call when updateTiming is ManualUpdate? I want to call it in LateUpdate to avoid delay one frame on transition. Cause the Animator update its state infor at LateUpdate, so if we set the updateTiming is InUpdate, the state of animator have not updated. This lead to when you transition to another state, at one frame later, the spine will be stayed at the previous state.

My current workaround approach is create a class inherit SkeletonMecanim and expose the UpdateAnimation function and call it at LateUpdate of another script. And it work properly, but I think I need a more official way.

public void ManualUpdate()
{
if (!valid || updateTiming != UpdateTiming.ManualUpdate) return;
UpdateAnimation();
}

Related Discussions
...

@nam_nguyen Thanks for reporting and sorry for the troubles! We have just added an Update(float deltaTime) method which serves as manual update. The method signature is kept the same as SkeletonAnimation since there will be a common interface with this method signature in spine-unity 4.2.

Issue ticket URL for later reference:
EsotericSoftware/spine-runtimes2389

Updated unitypackages will be released soon.

    Harald Thank you for your handly answer.
    Can I ask exactly when the new version will be released?

    P/s: I highly recommend you guys should have UpdateTiming.LateUpdate option, as far as I know, the visual should update in late update (like the Animator of Unity). If not, it's okay, I think I can handle it by myself.

      nam_nguyen P/s: I highly recommend you guys should have UpdateTiming.LateUpdate option, as far as I know, the visual should update in late update (like the Animator of Unity). If not, it's okay, I think I can handle it by myself.

      Thanks for the hint. To be precise, Unity's Mecanim animation update happens after Update and before any LateUpdate. Anyway, you are absolutely right that it's not good that the animator updates after the skeleton animation state was applied from it, making it a frame late. We will add the option accordingly.

        Harald Thank you, hope to see this update soon

        Harald Thank for your hard work. Have you tested this function? It seem like you meet a error same as me (when I try to create a LateUpdate function in my custom mecanim) if you set the UpdateTiming is InLateUpdate at initial. The way I fixed is make the LateUpdate can only call UpdateAnimation after the Initialize function is finished. Cause as I see, another place (like Initialize function) call the LateUpdate and occur the null exception.

          nam_nguyen Thanks for the hint! In my initial tests this problem did not surface, however when testing this on other Unity versions with different project settings, I was able to reproduce this issue. Thanks for reporting! We will let you know here once a bugfix is published.

          Harald It seem like it's working well. You did very quick. Just wondering why that issue did not apprear on other Unity versions. The Initialize function call the LateUpdate function when the translator have not been created. So, in theory, that bug does not depend on unity version. Sadly that I don't have time to investigate more haha.
          Anyway, thank you for your work, you did help me a lot.

          @nam_nguyen I assume it was due to different Enter Play Mode settings, and the different Unity version was more of a coincidence. Anyway, very glad it helped!