Hi, I am having real trouble trying to figure out why vSync is causing my main character to display jerky movement, but only when rotating.
My game is a top down 2D game.
Im not doing anything special here:
void FixedUpdate()
{
MovePlayer();
RotatePlayer();
}
void MovePlayer()
{
Vector2 inputVector = new Vector2(_player.GetAxis("Horizontal"), _player.GetAxis("Vertical"));
_rigidbody.AddForce(inputVector.normalized * (Time.deltaTime * Ref.playerManager.currentMoveSpeed), ForceMode2D.Force);
}
void RotatePlayer()
{
if (_player.GetAxis("R_Horizontal") != 0 || _player.GetAxis("R_Vertical") != 0)
{
_rotation = Mathf.Atan2(-_player.GetAxis("R_Horizontal"), _player.GetAxis("R_Vertical")) * Mathf.Rad2Deg;
Quaternion _newRot = Quaternion.Lerp(transform.rotation, Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, _rotation), Time.deltaTime * Ref.playerManager.currentRotationSpeed);
transform.rotation = _newRot;
}
}
So, with Vsync disable the game is buttery smooth, including player movement and rotation.
With Vsync enabled, the game runs fine, until the player rotates, then the movement goes all jerky.
I cant for the life of me see what would be causing the Rotate() function to introduce this jerkiness, especially in relation to vsync.
I have tried using Time.deltaTime and not using it, moving the rotation to Update() etc, nothing seems to solve it
Anyone have any ideas?