簡體   English   中英

除非在檢查器中更改字段,否則 Animation 無法正確播放

[英]Animation not playing correctly unless field is changed in inspector

我創建了一個動畫師來為我的角色手持武器制作動畫。 問題是動畫師不會為武器設置動畫,但它會為其他所有內容設置動畫。 我認為這是因為它正在生成並且還不存在,但我嘗試使用Invoke()IEnumerable來運行稍后播放 animation 的方法,但這並沒有改變任何東西。 我很沮喪,不明白我做錯了什么。

奇怪的是,如果我更改 Inspector 面板中的任何 Animator 屬性,animation 會自行修復(演示: https://imgur.com/a/BqZUI6N

我的動畫師的樣子: https://imgur.com/a/HZtBb0c (我已經驗證並且 animation 正在播放)

My object hierarchy: https://imgur.com/tvR4deZ (The object that doesn't animate is "Stick", the other objects that do animate are "ref_right_hand_grip" and "ref_left_hand_grip")

設置 animation 的代碼:

GameObject newHolding = null;
if (holding && holding.name != item.data.name)
{
    DestroyImmediate(holding);
    newHolding = Instantiate(item.data.holdingItem, holdingParent.transform, false);
    newHolding.name = item.data.name;
    holding = newHolding;
}
else if (!holding)
{

    newHolding = Instantiate(item.data.holdingItem, holdingParent.transform, false);
    newHolding.name = item.data.name;
    holding = newHolding;
}
anim.Play("equip_" + item.data.id);

編輯:我做了進一步的調查。 該問題可能與正在創建的 object 有關。 當我事先創建 object 並在玩家選擇它時簡單地啟用/禁用它時,animation 可以正常播放。 我應該提到我正在使用鏡像(網絡)

我解決此問題的方法是將 object 封裝在另一個 GameObject 中實例化(粘住),然后將封裝器動畫化。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM