1 回答

TA貢獻(xiàn)1906條經(jīng)驗 獲得超3個贊
public GameObject playerHead;
public GameObject character;
void Update()
{
? ? //check if the head is at a specific angle and if the mouse is moving
? ? if (playerHead.transform.localRotation.x >= 0.59f && Input.GetAxis("Mouse X") < 0) {
? ? ? ? //rotate the body at the speed of the mouse
? ? ? ? transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), 0));
? ? //repeat
? ? } else if (playerHead.transform.localRotation.x <= -0.59f && Input.GetAxis("Mouse X") > 0) {
? ? ? ? transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), 0));
? ? }
}

TA貢獻(xiàn)1852條經(jīng)驗 獲得超1個贊
可能的解決方案:( 我猜在你的項目中移動相機(jī)==移動頭部)
您只需使用(https://docs.unity3d.com/ScriptReference/Vector3.Angle.html)即可獲得頭部Transform.eulerAngles
和身體之間的相對角度,然后,在該方法中您可以手動旋轉(zhuǎn)身體,例如,(https:// docs.unity3d.com/ScriptReference/Rigidbody.MoveRotation.html)。Transform.eulerAngles
Vector3.Angle
Update
Rigidbody.MoveRotation
您還可以調(diào)整此旋轉(zhuǎn)以使其順利進(jìn)行。 (如果您添加一些代碼,我可以為您提供更多幫助)
- 1 回答
- 0 關(guān)注
- 144 瀏覽
添加回答
舉報