79395299

Date: 2025-01-28 22:22:44
Score: 1
Natty:
Report link

My mistake was that the camera was turning the player and the player himself was turning, there was a conflict, so when the camera was looking at the player's back, there was no shaking, because there was no rotation conflict, and when moving sideways relative to the camera, there was a conflict.

Player code

private void PlayerMove(Vector3 move)
{
    if(_isAttacking == true) return;
    _player.PlayerAnimator.SetFloat("Value", move.magnitude);
    var forward = _camera.transform.forward;
    var right = _camera.transform.right;
    forward.y = 0;
    right.y = 0;    
    forward.Normalize();
    right.Normalize();
    Vector3 movement = (move.x * right + move.y * forward);
    movement.y = 0;
    
    Vector3 val = _playerModel.PlayerSpeed * Time.fixedDeltaTime * movement;
    _player.PlayerRb.MovePosition(_player.PlayerRb.position + val);
    

    if (movement.magnitude != 0)
    {
        Quaternion targetRotation = Quaternion.LookRotation(val);
        _player.PlayerRb.rotation = Quaternion.Slerp(_player.PlayerRb.rotation,
            targetRotation, _playerModel.PlayerRotationSpeed * Time.fixedDeltaTime);
    }
}

I deleted these lines in the camera code.

private void ToUpdate()
{
    var targetRotation = Quaternion.Euler(0, _cameraMovement.x, 0);
    _player.transform.Rotate(new Vector3(0, targetRotation.x,0),Space.World);
}

https://youtu.be/P61KHd4aBxk new video

Reasons:
  • Blacklisted phrase (1): youtu.be
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Nikolay Stuff