【Unity】Animation Playable Bug、限制及解決方案匯總
先自薦一下我的PlayableGraph監(jiān)控工具,比官方的Visualizer好用得多:https://github.com/SolarianZ/UnityPlayableGraphMonitorTool
Bug
文中提及的各項Bug及解決方案的最小化測試工程可在此倉庫下載:https://github.com/zdirtywork 。
【可規(guī)避】UUM-30899
使用 AnimationClipPlayable
播放動畫時,調(diào)用 Playable.Pause()
方法后,角色仍繼續(xù)移動(姿態(tài)可以正常暫停)。
解決方案:對 AnimationClipPlayable
調(diào)用一次 SetTime()
方法。或者使用 SetSpeed(0)
代替 Pasue()
。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-35780
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-30899
【可規(guī)避】UUM-14492
已暫停的Playable會在角色的可見狀態(tài)改變時(進入相機視野,無論Scene窗口還是Game窗口)自動恢復(fù)播放。
解決方案:使用 SetSpeed(0)
代替 Pasue()
。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-15660
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-14492
【可規(guī)避】UUM-32824
將正在播放的PlayableGraph的UpdateMode設(shè)為 Manual
(這之后, PlayableGraph.IsPlaying()
方法會返回 false
),然后再調(diào)用 PlayableGraph.Play()
方法(這之后, PlayableGraph.IsPlaying()
方法會返回 true
,但仍需要手動驅(qū)動更新),然后再將PlayableGraph的UpdateMode設(shè)為任意 非Manual
值,PlayableGraph無法按預(yù)期恢復(fù)自動播放。
解決方案:調(diào)用 PlayableGraph.Stop()
方法,然后再調(diào)用 PlayableGraph.Play()
方法,強制刷新狀態(tài)。參考下方連接中的示例工程。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-37603
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-32824
【可規(guī)避】【不會修復(fù)】UUM-33177
連續(xù)調(diào)用2次 Playable.SetTime()
方法無法消除對跟運動的影響。例如,一個具有跟運動的動畫當(dāng)前播放到第5秒,使用 SetTime()
方法將其時間設(shè)置到10秒后,角色不僅會將自己的姿態(tài)變?yōu)閯赢嫷?0秒所對應(yīng)的姿態(tài),從第5到第10秒之間所應(yīng)產(chǎn)生的跟運動也會被施加到角色身上,具體表現(xiàn)就是角色位置突變。
Unity表示不會修復(fù)此Bug。
解決方案:在 AnimationClipPlayable
后面接一個 AniamtionScriptPlayable
,在其Job中手動將時間差導(dǎo)致的跟運動數(shù)據(jù)剔除。參考下方連接中的示例工程。然后你會遇到UUM-36098。
- https://github.com/zdirtywork/WillNotFix_Unity-Bug-Report-Playable-IN-36756
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-33177
【可規(guī)避】UUM-36098
在使用Humanoid動畫時,通過 AnimationStream.velocity
屬性修改跟運動速度不生效。
解決方案:不要用 Animator
自己的跟運動計算方法,而是手動從 AnimationStream
中收集跟運動數(shù)據(jù),然后手動施加給角色。參考下方連接中的示例工程。然后你會遇到UUM-33952。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-41394
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-36098
【Unity 2022無法復(fù)現(xiàn)】【不會修復(fù)】UUM-33952
Time.timeScale
的值會影響 AnimationStream
中動畫跟運動旋轉(zhuǎn)數(shù)據(jù)的值。很神奇的Bug,具體表現(xiàn)是,當(dāng) Time.timeScale
的值大于 0.85
時,從 AnimationStream
中取出的跟運動旋轉(zhuǎn)數(shù)據(jù)和 Animator
中的跟運動旋轉(zhuǎn)數(shù)據(jù)不一致,并且在 Time.timeScale
的值大于 1
后, Time.timeScale
的值越大,兩者中的跟運動旋轉(zhuǎn)數(shù)據(jù)差距越小。情況非常多,參考下方連接中的示例工程。
我只在簡單的PlayableGraph中注意到此問題,當(dāng)PlayableGraph連接的復(fù)雜了以后,這個問題就變得不明顯了。另外,使用UUM-36098中提及的方式手動計算跟運動時,角色會有輕微滑步,估計和這個Bug有關(guān)。
Unity表示不會修復(fù)此Bug。但我在Unity 2022中沒能復(fù)現(xiàn)這個問題,可能他們說的是與此問題相關(guān)的其他底層邏輯Bug不會被修復(fù)。
- https://github.com/zdirtywork/WillNotFix_Unity-Bug-Report-Playable-IN-38581
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-33952
【可規(guī)避】【不會修復(fù)】UUM-34442
當(dāng) AnimationScriptPlayable
輸入到了 ScriptPlayable<T>
的非第0個輸入端口時,其Job中的 ProcessRootMotion()
方法和 ProcessAnimation()
方法不會執(zhí)行。
Unity表示不會修復(fù)此Bug。
解決方案:使 ScriptPlayable<T>
只有1個輸入端口,然后在 ScriptPlayable<T>
前輸入一個 AnimationMixerPlayable
或 AnimationLayerMixerPlayable
,把原本 ScriptPlayable<T>
上的多個輸入端口改為Mixer的多個輸入端口。參考下方連接中的示例工程。
- https://github.com/zdirtywork/WillNotFix_Unity-Bug-Report-Playable-IN-39561
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-34442
【可規(guī)避】UUM-33944
當(dāng) AnimationScriptPlayable
的有效權(quán)重不為 1
時,在其Job中通過 PropertyStreamHandle
修改動畫曲線值不生效。
解決方案:在 Animator
上綁定一個名為 GravityWeight
的屬性。暫不清楚此方法會不會造成其他負面影響。參考下方連接中的示例工程。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-38805
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-33944
UUM-31822
當(dāng) Animator.applyRootMotion
屬性為 false
時,綁定 Animator
組件所處節(jié)點的 TransformStreamHandle
會導(dǎo)致角色位置異常。
- https://github.com/zdirtywork/Unity-Bug-Report-Playable-IN-35588
- https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-31822
限制/規(guī)則
PlayableGraph.IsPlaying()
方法的返回值
Editor中逐幀播放時, PlayableGraph.IsPlaying()
方法總是返回 false
。我對此提過Bug單,但Unity說設(shè)計如此不是Bug。我覺得這個設(shè)計太爛了!原因有二:
- Runtime應(yīng)該對Editor無感知,逐幀播放是存粹的Editor功能,而它卻改變了Runtime接口的行為。
- 如果Runtime代碼依據(jù)
PlayableGraph.IsPlaying()
方法的返回值執(zhí)行不同邏輯,這里很有可能導(dǎo)致逐幀調(diào)試時出現(xiàn)Bug。
AnimationScriptPlayable
的輸入不受權(quán)重影響
AnimationScriptPlayable
預(yù)期用戶手動處理其輸入Playable中的數(shù)據(jù),因此,連接輸入Playable時設(shè)置的權(quán)重不會實際作用到輸入數(shù)據(jù)上,而是要用戶手動處理。
角色未被渲染時, AnimationScriptPlayable
的Job中的 ProcessAnimation()
方法不會執(zhí)行
符合預(yù)期,因為角色不可見時計算其姿態(tài)通常沒有意義,浪費性能。如果希望在角色不可見時仍執(zhí)行 ProcessAnimation()
方法,可以將 Animator.cullingMode
設(shè)為 AlwaysAnimate
。文章來源:http://www.zghlxwxcb.cn/news/detail-789043.html
沒有直接或間接輸出到 AnimationPlayableOutput
的 AnimationScriptPlayable
不會執(zhí)行其Job中的 ProcessRootMotion()
方法和 ProcessAnimation()
方法
符合預(yù)期,因為這種情況下動畫數(shù)據(jù)始終無法施加到角色身上,計算了也是白算,浪費性能。文章來源地址http://www.zghlxwxcb.cn/news/detail-789043.html
到了這里,關(guān)于【Unity】Animation Playable Bug、限制及解決方案匯總的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!