Advertisement
Eonirr

Untitled

Mar 22nd, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Vector3 inputDirection = new Vector3(_input.move.x, 0.0f, _input.move.y).normalized;
  2.  
  3. if (_input.move != Vector2.zero)
  4. {
  5. _targetRotation = Mathf.Atan2(inputDirection.x, inputDirection.z) * Mathf.Rad2Deg + _playerCamera.transform.eulerAngles.y;
  6. float rotation = Mathf.SmoothDampAngle(transform.eulerAngles.y, _targetRotation, ref _rotationVelocity, RotationSmoothTime);
  7.  
  8. transform.rotation = Quaternion.Euler(0.0f, rotation, 0.0f);
  9. }
  10.  
  11. Vector3 direction = Quaternion.Euler(0.0f, _targetRotation, 0.0f) * Vector3.forward;
  12.  
  13. _controller.Move(direction.normalized * (_speed * Time.deltaTime) + new Vector3(0.0f, _verticalVelocity, 0.0f) * Time.deltaTime);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement