KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
66 stars 8 forks source link

Playable. GetTime() in LateUpdate returns 0 at the current frame of the second playback action #266

Closed raykingqd closed 1 year ago

raykingqd commented 1 year ago

Environment

Description

I play a and b actions in update, and take the time in lateupdate. After a is played twice, when the second time is played, Lateupdate will get a time of 0, and the first time will get a time of delta

Reproduction

Steps to reproduce the bug:

  1. code this
  2. private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                _Animancer.Play(_Action,0,FadeMode.FixedSpeed);
                Debug.Log($"Play CurrentState !!!!!! Time.frameCount{Time.frameCount}");
            }
            if (Input.GetMouseButtonDown(1))
            {
                _Animancer.Play(_Idle,0,FadeMode.FixedSpeed);
                Debug.Log($"Play CurrentState !!!!! Time.frameCount{Time.frameCount}");
            }
        }
        private void LateUpdate()
        {
             Debug.Log($"LateUpdate CurrentState {_Animancer.Layers[0].CurrentState.Time} Time.frameCount{Time.frameCount}");
        }
  3. Enter Play Mode
  4. See the error in the Console.
  5. first firstprintpng 6.second time thumbnail_f52d1f737e256e40aa383e1598add6a4

thumbnail_08a603d36e59db49a050b4b3869f1914

KybernetikGames commented 1 year ago

That behaviour is controlled by the Playables API so Animancer has no control over it. I reported it as a bug to Unity ages ago, but they said it's by design.

Basically, when a Playable is created its first update will move its time forward.

But when something sets a Playable's time, it will be left at that time by the next update and only continue advancing after that. So when you play something else it rewinds your animation to 0 and since it isn't playing its next update only occurs next time you start playing it again where it stays at 0 for that frame.

raykingqd commented 1 year ago

But we are concerned about this, so I use animancer.Evaluate(), do you have any suggestions for better performance? For example ((IPlayableWrapper)_Animancer.Layers[0]).Playable.GetGraph().Evaluate()?

raykingqd commented 1 year ago

Also, can you send me the link to the bug you submitted to unity?

KybernetikGames commented 1 year ago

Both of those Evaluate calls will do the exact same thing and there's no way to update only part of the graph.

Here's the Issue Tracker Link for my bug report. They've marked it as fixed in 2021.2, but I just tested it and it's not fixed. Their resolution note also seems completely irrelevant so I'm thinking they must have misunderstood the actual issue.

I'll report another bug because I agree that this behaviour is bad.

raykingqd commented 1 year ago

这两个Evaluate调用将做完全相同的事情,并且无法只更新图形的一部分。

这是我的错误报告的问题跟踪器链接。他们已将其标记为已在 2021.2 中修复,但我刚刚对其进行了测试,但并未修复。他们的决议说明似乎也完全无关紧要,所以我认为他们一定误解了实际问题。

我将报告另一个错误,因为我同意这种行为是不好的。

Thank you for your help

KybernetikGames commented 1 year ago

The new bug report is case IN-34574. If they make a public Issue Tracker page for it I'll post it here.

Until then, I'll close this issue because there isn't anything Animancer can do about it.

KybernetikGames commented 1 year ago

Here's the Issue Tracker page. It says "under consideration" so maybe there is hope of it getting fixed.