Camera moveTowards stuttering in place?

Hello! I’m trying to make my camera move from one point to another when pressing a button. When the button is pressed, it sets the variable “moveToEditPos” to true. This is what i tried so far:

	void Update() {
		print (moveToEditPos.ToString ());
		//if(Vector3.Distance(Camera.main.transform.position,editModePos) > 0.1f)
			Camera.main.transform.position = Vector3.MoveTowards (transform.position,editModePos, 15F * Time.deltaTime);

I get this, however:(sorry for the quality…)

It just stutters in place. Why is this happening?

What is happening is that every frame where moveToEditPos = true, your MoveTowards() method is returning the same vector and moving the camera to the same position over and over. You are not “stepping” the camera towards its destination point, but rather are immediately setting its position to the same point along the line connecting transform.position (of your script’s parent gameobject) and editModePos. Consult the documentation link below to see the proper way to use MoveTowards().

You need to be incrementing the camera’s position towards its destination position each frame.

Try replacing line 5 with Camera.main.transform.position = Vector3.MoveTowards (Camera.main.transform.position,editModePos, 15F * Time.deltaTime); and see if this is the behavior that you desire.