# Player doesn't move smoothly, when trying to follow position between cursor and player

When my player moves, moving the camera looks like the camera is teleporting to the player, and then after loading teleporting again. I want to make it move smoothly.

When the camera is following the player position, it is moving smoothly.

Camera following code:

private void Update()
{
Vector3 position = GetFollowingPoint();
position = new Vector3(
Mathf.Clamp(position.x,
Bounds.bounds.min.x + Camera.orthographicSize * Screen.width / Screen.height,
Bounds.bounds.max.x - Camera.orthographicSize * Screen.width / Screen.height),
Mathf.Clamp(position.y,
Bounds.bounds.min.y + Camera.orthographicSize,
Bounds.bounds.max.y - Camera.orthographicSize),
transform.position.z);

transform.position = position;
}


GetFollowingPoint():

return Player.transform.position + (cursor.transform.position - Player.transform.position) / 3;


Player movement: rigidbody.velocity = Vector in FixedUpdate(), Input with Input.GetKey() and Vector += Vector2.up/down/left/right.

Interpolation in Rigidbody set to Interpolate.

• How do you move your player? If the problem is only visible when the player moves, then that code could be part of the cause. Jun 9, 2019 at 13:24
• @DMGregory With rigidbody.velocity = Vector in FixedUpdate(), Input with Input.GetKey() and Vector += Vector2.up/down/left/right Jun 9, 2019 at 15:21
• Ahhh, be sure to include that in your question. Have you configured interpolation on your Rigidbody? Jun 9, 2019 at 15:22
• @DMGregory Yes, set to Interpolate Jun 9, 2019 at 15:23

The problem lies with the call of transform.position = position;

When you assign your new position directly to the transform of the object, you are hard-setting the position. You have to do what is called "Interpolation" which calculates an appropriate point between the current position and the destination you want it to approach. This smoothes out the movement per frame to a more reasonable amount.

The call you want to make is Vector3.MoveTowards(_current_position, _new_position, _speed);

You can see an example in the Unity Manual for Vector3.MoveTowards