[英]How to increase rotation angle with Unity using Quaternion
在我的Unity場景中,我試圖旋轉帶有頭部運動的立方體。 這是我的代碼:
m_cubeName.rotation = Quaternion.Lerp(m_cubeName.rotation, m_Camera.rotation, Time.deltaTime);
它似乎可以工作並且旋轉與頭部完全相同的角度。 我想使用一個乘數,以便當頭部旋轉(例如1度)時,立方體旋轉2度。
那么,如何將四元數旋轉值轉換為可以乘以因子的乘積呢?
要將多維數據集旋轉2倍,只需將其旋轉兩次:
Quaternion doubleCameraRotation = m_Camera.rotation * m_Camera.rotation;
m_cubeName.rotation = Quaternion.Lerp(
m_cubeName.rotation,
doubleCameraRotation,
Time.deltaTime);
要將旋轉乘以非整數因子,可以使用Quaternion.LerpUnclamped
(或SlerpUnclamped
以提高精度),然后將縮放因子傳遞為t
。 例如:
Quaternion doubleCameraRotation =
Quaternion.LerpUnclamped(Quaternion.identity, m_Camera.rotation, 2f);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.