Advertisement
Eonirr

Untitled

Jan 19th, 2024
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. private void CameraRotation()
  2. {
  3. if (_input.look.sqrMagnitude >= _threshold && !LockCameraPosition)
  4. {
  5. float deltaTimeMultiplier = isMouse ? 1.0f : Time.deltaTime;
  6.  
  7. _cameraTargetYaw += _input.look.x * deltaTimeMultiplier;
  8. _cameraTarrgetPitch += _input.look.y * deltaTimeMultiplier;
  9. }
  10.  
  11. _cameraTargetYaw = ClampAngle(_cameraTargetYaw, float.MinValue, float.MaxValue);
  12. _cameraTarrgetPitch = ClampAngle(_cameraTarrgetPitch, BottomClamp, TopClamp);
  13.  
  14. cameraTarget.transform.rotation = Quaternion.Euler(_cameraTarrgetPitch + CameraAngleOverride, _cameraTargetYaw, 0.0f);
  15. }
  16.  
  17. private void Move()
  18. {
  19. Vector3 inputDirection = new Vector3(_input.move.x, 0.0f, _input.move.y).normalized;
  20.  
  21. if (_input.move != Vector2.zero)
  22. {
  23. _targetRotation = Mathf.Atan2(inputDirection.x, inputDirection.z) * Mathf.Rad2Deg + _playerCamera.transform.eulerAngles.y;
  24. float rotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _targetRotation, ref _rotationVelocity,
  25. RotationSmoothTime);
  26.  
  27. transform.rotation = Quaternion.Euler(0.0f, rotation, 0.0f);
  28. }
  29.  
  30. Vector3 direction = Quaternion.Euler(0.0f, _targetRotation, 0.0f) * Vector3.forward;
  31.  
  32. _controller.Move(direction.normalized * (_speed * Time.deltaTime) + new Vector3(0.0f, _verticalVelocity, 0.0f) * Time.deltaTime);
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement