smooth transition between camera position

hi,

im having a bit of a problem i cant get a smooth transition between camera position.
the code i have changes the camera possition but not smoothly, it just jumps to next possition

public int cam_index = 0;
public Transform[] cam_pos;
public Camera c;
public float smooth =1;
private Transform cam_cur_pos = c.position;

void Update ()
{

if (cam_index == 0) {
cam_cur_pos .transform.position = Vector3.Slerp (cam_pos [cam_index].position, cam_pos [0].position, Time.deltaTime *smooth);
cam_cur_pos .transform.rotation = Quaternion.Slerp (cam_pos [cam_index].rotation, cam_pos [0].rotation, Time.deltaTime *smooth);

}
if (cam_index == 1) {
cam_cur_pos .transform.position = Vector3.Slerp (cam_pos [cam_index].position, cam_pos [1].position, Time.deltaTime *smooth);
cam_cur_pos .transform.rotation = Quaternion.Slerp (cam_pos [cam_index].rotation, cam_pos [1].rotation, Time.deltaTime *smooth);

}
if (cam_index == 2) {
cam_cur_pos .transform.position = Vector3.Slerp (cam_pos [cam_index].position, cam_pos [2].position, Time.deltaTime *smooth);
cam_cur_pos .transform.rotation = Quaternion.Slerp (cam_pos [cam_index].rotation, cam_pos [2].rotation, Time.deltaTime *smooth);
}

c.transform.position = cam_cur_pos .transform.position;
c.transform.rotation = cam_cur_pos .transform.rotation;

}

void OnGUI ()
{
if (GUI.Button (new Rect ((Screen.width / 2) + 100, Screen.height / 2, 100, 100), "Muda Camera")) {	
cam ();
}
}

void cam ()
{
cam_index++;
if (cam_index >= cam_pos.Length) {
cam_index = 0;
}
}

is it because distance is to short? its just 0,2 on the x axis but the rotation is 180º …

thx in advance

solved

void Update()
{
			go.transform.position = Vector3.Slerp (c.transform.position, cam_pos [cam_index].position, Time.deltaTime * smooth);
			go.transform.rotation = Quaternion.Slerp (c.transform.rotation, cam_pos [cam_index].rotation,Time.deltaTime * smooth);
	
		c.transform.position = go.transform.position;
		c.transform.rotation = go.transform.rotation;
}

thx for all the help

What if you use Vector3.MoveTowards instead of Slerp?

nop did not work still jumping to next position

That is because every time you increment the camera you start slerping FROM the new camera position. You want to slerp from the PREVIOUS camera position to the Current camera position.

You code seems a bit bloated. Why don’t you move the camera instead of changing the position of the transform holding the coordinate?

Also, why do you have an array of transforms to store the positions? You can also do that with Vector3’s.

public Camera c;
public int cam_index = 0;
public Vector3[] cam_pos;
public int smooth =1;

function Update()
{
       if(cam_pos[cam_index] != c.position)
       {
               c.position = Vector3.MoveTowards(c.position, cam_pos[cam_index],  Time.deltaTime *smooth);
       }
}

This should do the same.

the array of transform is there beacause i want to not only change the position but also the rotation, and in my game it will have several possible positions and orientations for the user to pick from. i want the user to cycle through the game views but whit a smooth transition, from what i have read the way to do this is to have only one camera and that camera changes positions.

btw even if its still not working thx for help