Teleport problem

{

    public GameObject objToTP;
public GameObject tpLoc;

void OnTriggerEnter(Collider other)
{
	if ((other.gameObject.tag == "Player")) 
	{
		objToTP.transform.position = tpLoc.transform.position;
		Debug.Log ("Teleported");
	}
}
void OnTriggerExit()
{
	print ("Teleport.Success");
}

}

I am trying to teleport my FPS controller by adding this script to the teleport trigger. I also added an empty as the tpLoc and the FPS controller to the objToTP. It is giving me the “Teleported” and “Teleport.Success” in the console but the fps controller is not being teleported. I think that I should mention that I have the same code just with a UI and having to press E. That one works. I also have this one in a different scene.

That rather suggests that you haven’t assigned the correcy object to the objToTP variable. However, you really don’t need it anyway - if it’s the player that enters the trigger and the player that you want to teleport, you can change your code to:

void OnTriggerEnter(Collider other)
{
 if (other.gameObject.tag == "Player")
 {
     other.transform.position = tpLoc.transform.position;
     Debug.Log ("Teleported");
 }
}

Thanks a lot but I found out that I applied the script to the wrong scene. :smiley: