rotation glitching

When I press forward, I want the character to start rotating towards the camera. After returning to this issue after multiple weeks I have now finally found something that nearly works. However, the player will start shaking once it’s aligned with the camera, because transform.rotation.y changes.
What’s the best way to solve this?

if(Input.GetAxis("Vertical") > 0){
			if(cam.localRotation.y*360 < 180 - rotspeed){
				transform.Rotate(0,rotspeed*Time.deltaTime,0);
			}
			else if(cam.localRotation.y*360 > 180 - rotspeed){
				transform.Rotate(0,-rotspeed*Time.deltaTime,0);
			}
		}

Yeah, it’s a bit of a hack, but it works.

if(Input.GetAxis("Vertical") > 0){
			if(cam.localRotation.y*360 < antiglitch  cam.localRotation.y*360 > -antiglitch){
			}
			else if(cam.localRotation.y*360 < 180 - rotspeed){
				transform.Rotate(0,rotspeed*Time.deltaTime,0);
			}
			else if(cam.localRotation.y*360 > 180 - rotspeed){
				transform.Rotate(0,-rotspeed*Time.deltaTime,0);
			}
		}