Mathf.Clamp は、maxValue に制限するのではなく、maxValue に達すると、オイラーアングルを minValue にリセットしています。私はこれを試しました:
rotateX = Input.GetAxis("Mouse X") * senseX;
player.transform.Rotate(player.up, Mathf.Deg2Rad * rotateX, Space.World);
playerXRotation = player.eulerAngles;
while (playerXRotation.y > 180f)
playerXRotation.y -= 360f;
Debug.Log("Y Rotation: " + playerXRotation.y);
playerXRotation.y = Mathf.Clamp(playerXRotation.y, lowLimitY, highLimitY);
player.transform.eulerAngles = playerXRotation;
この :
rotate = Input.GetAxis("Mouse X") * senseX;
rotation = player.transform.eulerAngles;
rotation.y += rotate * RateOfRotate;
while (rotation.y > 180)
{
rotation.y -= 360;
}
rotation.y = Mathf.Clamp(rotation.y, lowLimitY, highLimitY);
player.transform.eulerAngles = rotation;
ここでは、両方のケースで lowLimitY = 0 と highLimitY = 180 です。私はこれで立ち往生しており、それを回避する方法がわかりません。どんな助けでも大歓迎です。