Jerky Camera and Varying Translate speeds

I am making a 2D game, I need the camera to follow the player only on the x axis.

camera.main.transform.position.x = player.position.x;

this results in extremly jerky movement.
Also I use a transform.translate to keep the player constantly moving at a constant speed. However I also have the player rotating on the z axis, the more the player rotates on the z axis the slower he moves.


//nothing fancy there not sure why change in angle would //cause it to slow down...

You could try putting the Camera update into a LateUpdate() method instead of Update(). That will guarantee that it happens after the player object has moved. That may help.

Other than that, you can try smoothly moving to follow the player by doing something like this instead of snapping directly to the player every frame:

camera.main.transform.position.x = Mathf.Lerp(camera.main.transform.position.x, player.position.x, 5.0f * Time.deltaTime);

The 5.0f is a damping factor that you can tweak to determine how slow or fast the camera moves to the player’s position