Half working Teleport Script

Hello community,

I am part of a group making a historical visualization. I am trying to adapt and update a pause/teleport script that was used in a previous project that ran in Unity 3.5. The script is supposed to allow the user to hit escape, then click on a GUI button and be teleported to the corresponding location. This is my first attempt at scripting in Unity and I have only a cursory knowledge of Javascript, so I kind of fumbling my way through it.

I have got the pause and gui functions to work. Unfortunately, when you click on button to teleport, it is like only the camera is teleported, and as soon as the you move, the you back at the starting point again. I pasted my code at them bottom. I have left in what I commented out from the original script, as maybe someone with more knowledge than me can see how it was done previously. I have a feeling it has something to do with enabling and disabling the camera.

Any help is greatly appreciated.

#pragma strict

public var locations: Transform[];
private var paused : boolean;
private var guiSkin : GUISkin;
//private var fpcMouseLook : MouseLook;
//private var camMouseLook : MouseLook;
//private var crosshairScript : CrosshairScript;
private var fpc : GameObject;

// private var minimap : MinimapScript;
function Start() 
{
	Cursor.lockState = CursorLockMode.Locked;
	Cursor.visible = false;
}

function Awake() 
{
	fpc = GameObject.Find("FirstPersonCharacter");
	//fpcMouseLook = fpc.GetComponent(MouseLook);
	//camMouseLook = GameObject.Find("MainCamera").GetComponent(MouseLook);
	//crosshairScript = GameObject.Find("Crosshair").GetComponent(CrosshairScript);
}

function Update () 
{
	if(Input.GetKeyDown("escape")) 
	{
		paused = !paused;
	}
	if(paused) 
	{
		Time.timeScale = 0;
		Cursor.lockState = CursorLockMode.None;
		Cursor.visible = true;
		AudioListener.pause = true;
		//enableCamera(false);
		//crosshairScript.hide();
	}
	else 
	{
		Time.timeScale = 1;
		Cursor.lockState = CursorLockMode.Locked;
		Cursor.visible = false;
		AudioListener.pause = false;
		//enableCamera(true);
		//crosshairScript.show();
	}
}

function OnGUI () 
{
	GUI.skin = guiSkin;
	if(paused) 
	{
		GUI.Box(Rect(-5, -5, Screen.width+10, Screen.height+10), "");
		GUI.Box(Rect(Screen.width/2 - 265, Screen.height/2, 530, 130), "Jump to a location:");
		
		// Resume button
		if (GUI.Button (Rect (Screen.width/2 - 60, Screen.height/2 - 80, 120, 40), "Resume")) 
		{
			paused = false;
		}
		                                     

		// Go to Apartment 12-8-A
		if (GUI.Button (Rect (Screen.width/2 - 190, Screen.height/2 + 30, 120, 40), "Apartment 12-8-A")) 
		{
			// setPosition(289, 2, 225, 318);
			fpc.transform.position = locations[0].position;
			paused = false;
		}

		// Go to Mess Hall
		if (GUI.Button (Rect (Screen.width/2 - 60, Screen.height/2 + 30, 120, 40), "Mess Hall")) 
		{
			// setPosition(287, 2, 227, 270);
			fpc.transform.position = locations[1].position;
			paused = false;
		}

		// Go to Start Location
		if (GUI.Button (Rect (Screen.width/2 + 70, Screen.height/2 + 30, 120, 40), "Start Location")) 
		{
			// setPosition(245, 2, 260, 245);
			fpc.transform.position = locations[2].position;
			paused = false;
		}

	}
}

function showPause() 
{
	paused = true;
}

function hidePause() 
{
	paused = false;
}

function isPaused()
{
	return paused;
}

//function enableCamera(enable : boolean) 
//{
	//fpcMouseLook.enabled = enable;
	//camMouseLook.enabled = enable;
//}

//function setPosition(x : float, y : float, z : float, r : float)
//{
	// minimap.setPosition(x, z);
	// fpc.transform.position.x = x;
	// fpc.transform.position.y = y;
	// fpc.transform.position.z = z;
	// fpcMouseLook.SetRotationY = r;
    // fpcMouseLook.rotationY = r;
//}

And… I fixed it. My problem was the script was placed on the FirstPersonCharacter, but needed to be placed on the parent FPScontroller. So it works as intended!