Am working on the controls and camera movement for my character. What I am trying to do is have the character head be able to rotate left and right and then when the head is rotated a certain amount, the whole character rotates around. I have kinda of done it, the head can move smoothly, but it stutters when it starts rotating everything.
Hopefully it is visible in this GIF.
You may be able to see that the head does rotate smoothly, but when the body starts rotating, it stutters.
Here is the code that is in LateUpdate that handles all the rotations.
this.current_rotation = Quaternion.Lerp(this.current_rotation, Quaternion.Euler(new Vector3(this.pitch, this.yaw, 0)), this.mouse_sensitivity * Time.deltaTime);
this.cam.transform.rotation = this.current_rotation;
this.head.transform.rotation = this.current_rotation;
if(this.head.transform.localRotation.y > 0.3 || this.head.transform.localRotation.y < -0.3){
Quaternion from = Quaternion.Euler(0, this.player.transform.eulerAngles.y, 0);
Quaternion to = Quaternion.Euler(0, this.current_rotation.eulerAngles.y, 0);
Quaternion q = Quaternion.Lerp(from, to, this.mouse_sensitivity * Time.deltaTime);
this.player.transform.rotation = q;
}