[英]Why the object is never rotating towards the target?
void Update()
{
if (pickUp)
{
if(Roll.hasStopped)
{
animator.SetTrigger("Walk Forward");
Vector3 targetDirection = (target.position - transform.position).normalized;
target.rotation = Quaternion.LookRotation(targetDirection);
transform.rotation = Quaternion.RotateTowards(transform.rotation, target.rotation, Time.deltaTime);
}
}
}
變換是玩家,他開始向前走“向前走”,但他從不向目標旋轉。 他一直往前走。
“向前走”是我在動畫控制器中使用的觸發參數,用於轉換到具有 HumanoidWalk 動畫的狀態。
問題是為什么變換沒有向目標旋轉而是繼續向前走?
也許您正在使用 animator.SetTrigger 覆蓋旋轉? Idk 動畫太多了,但對我來說似乎很奇怪 animator.SetTrigger 在每一幀中都被調用,之后沒有任何標志來停止一遍又一遍地調用它。 從我在文檔中看到的內容來看,這個觸發器在某個事件(即按下一個鍵)之后被調用,但不是在每一幀中都被調用。 希望能幫助到你 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.