Since updating to Unity 5.1 today, I’ve noticed that my camera’s motion has become quite choppy. Here’s the code I’m using within the Update function:
cameraObject.transform.position = Vector3.Lerp(cameraObject.transform.position, new Vector3(player.transform.position.x, player.transform.position.y, -10), cameraSpeed * Time.deltaTime);
Basically, I’m having the camera follow the player using a Lerp, so that the camera has a little bit of drag. This was working completely fine prior to the 5.1 update.
As a test, I tried having my camera follow the player’s position 1:1, as seen in this code:
cameraObject.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, -10);
This works completely fine, no choppiness at all.
I should also note that my camera includes a RigidBody2D that has Interpolate set to “Interpolate”. “None” and “Extrapolate” settings cause the camera to go a bit haywire. Is there maybe some better, alternative way of achieving the sort of camera motion I’m looking for?