Jerky, choppy camera motion in Unity 5.1 using Lerp

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?

You should not be using lerp, because you are basing your movement off of Time.deltaTime you are going to get results that work but the it is fundamentally wrong to use Time.deltaTime with lerp. I mean it works but you should use MoveTowards instead.

This tutorial at about minute 12 explains why.

http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/tips-tricks-4

OK, I figured out the solution. One thing I failed to mention was that my camera was nested under another object, which also had a RigidBody2D. Having two of these was causing things to get messed up. I removed one of them and set Interpolation to “Extrapolate”, and everything works fine.