# Smooth camera movement between followed objects

I have 2d game where my camera follows the player. Simplified, it copies the player position as its own.

Now I have some other object in the game, that I want to camera to follow. This is easy enough by not setting the camera's position with the player's, but with the position of the other object.

The problem is that this camera movement is instant. I'd like to have a more smooth transition (e.g. panning over the level to the given object).

How can I achieve this?

You need to interpolate between the camera's position and the target position. It looks like libgdx has a Vector2.lerp() linear interpolation method that you can use, however if you want something that has a smoother ease in/out you'll need to use another method, which it seems you can do using Vector2.interpolate(). Call one of these methods every frame and your camera's position will move smoothly to the target position instead of snapping.