Код: Выделить всё
void TiltMovement()
{
float tiltRight = Input.GetKey(GameManager.Instance.InputManager.GetKey("TiltRight")) ? 1 : Input.GetKey(GameManager.Instance.InputManager.GetKey("TiltLeft")) ? -1 : 0;
if (tiltRight != 0)
{
// Calculate the rotation amount based on the tilt input
float tiltAmount = tiltRight * tiltSpeed * Time.deltaTime;
// Apply Z-axis rotation in local space
transform.Rotate(Vector3.forward, -tiltAmount, Space.Self);
}
< /code>
My Mouse Look < /p>
void HandleMouseLook()
{
float mouseX = Input.GetAxis("Mouse X") * lookSpeed * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * lookSpeed * Time.deltaTime;
targetMouseDelta = new Vector2(mouseX, mouseY);
currentMouseDelta = Vector2.Lerp(currentMouseDelta, targetMouseDelta, smoothFactor * Time.deltaTime);
rotationY += currentMouseDelta.x;
rotationX -= currentMouseDelta.y;
rotationX = Mathf.Clamp(rotationX, -clampAngle, clampAngle);
// Apply rotations in local space
transform.Rotate(Vector3.up, rotationY, Space.Self); // Rotate around local Y axis
transform.Rotate(Vector3.right, rotationX, Space.Self); // Rotate around local X axis
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... on-is-done