๋ง์ฐ์ค ์ข์ฐ๋ก ์์ง์ด๋ฉด ์บ๋ฆญํฐ ํ์ ํ๊ณ ์์๋ ์์ง์ด๋ฉด ์นด๋ฉ๋ผ ํ์ ํ๋ ค๋๋ฐ ์ด๋ ๊ฒ ๋๋ค์
private void Update()
{
ApplyRotation();
}
private void ApplyRotation()
{
CarachterRoatation();
CameraRotation();
}
private void CameraRotation()
{
float _cameraRotationUpDown = _mouseInput.y * mouseSensitivity.vertical;
currentCameraRotationUpDown -= _cameraRotationUpDown;
currentCameraRotationUpDown = Mathf.Clamp(currentCameraRotationUpDown, cameraAngle.min, cameraAngle.max);
_mainCamera.transform.localEulerAngles = new Vector3(currentCameraRotationUpDown, 0f, 0f);
}
private void CarachterRoatation()
{
currentCameraRotationLeftRight += _mouseInput.x * mouseSensitivity.horizontal;
var targetRotation = Quaternion.LookRotation(new Vector3(0.0f, currentCameraRotationLeftRight, 0.0f));
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
Debug.Log(currentCameraRotationLeftRight + " " +targetRotation);
}
public void Look(InputAction.CallbackContext context)
{
_mouseInput = context.ReadValue<Vector2>();
}
public struct MouseSensitivity
{
public float horizontal;
public float vertical;
public bool invertHorizontal;
public bool invertVertical;
}
๋ชธ์ด๋ ๋จธ๋ฆฌ๋ ๋ฐ๋ก ์ค๋ธ์ ํธ ๋ง๋ค์ด๋ณด๋ฉด ๋ ๋ฏ?
๋น์ค๋ธ์ ํธ ๋ง๋ค์ด์ ์นด๋ฉ๋ผ ๋ฃ๊ณ ์บ๋ฆญํฐ ๋์์์ ๋ฐ๋ผ๋ค๋๊ฒ ๋ง๋์ . ์์ง์ผ๋ ๊ธ๋ง ์์ง์ด๋ฉด ๋จ