簡體   English   中英

如何從右側旋轉到目標點?

[英]How can I do a rotation to the target point from right?

我有一個輪子。 我希望輪子向目標點旋轉。

在 1-2-3-4-5 右轉。 但它向左轉至 6-7-8 點。 因為從左側轉彎需要更短的路。 (這些點保存在“目標”變量中)

我希望輪子始終向右轉動以指向目標。 如何從右側旋轉到目標點?

在此處輸入圖像描述

我的代碼:

 targetRotation = Quaternion.LookRotation(new Vector3(
            target.transform.position.x,
            0,
            target.transform.position.z)
            - transform.position);
    transform.rotation =
        Quaternion.Lerp(transform.rotation,
        targetRotation,
        3f * Time.deltaTime)
        ;

試試 LiterallyJeff 的這個解決方案。 統一論壇鏈接

暫無
暫無

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

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