Teleporting Player doesn't work as expected?

Hi guys!

So I have a very strange problem again. I wrote a basic teleportation script which is working fine at the first point. I enter the trigger, and it teleports me to a given gameobject’s position. However when I do the same on another trigger because I want a way back to my original position, for some reason it teleports me to the first teleport’s target coordination.
To better understand:
Teleport1 - Teleport1Target
Teleport2 - Teleport1Target

Obviously I want the Teleport2 to lead to Teleport2Target, but it doesn’t even after I make sure that it has the right gameobject as reference in the inspector.

Here is the code:

#pragma strict

private var Player : GameObject;
var Position : Transform;
var delay : float;
private var IsInRange : boolean;

function Start()
{
	Player = GameObject.FindGameObjectWithTag("Player");
}

function OnTriggerStay (theCollider : Collider)
{
	if (theCollider.tag == "Player")
	{
		IsInRange = true;
		if(delay <= 0)
		{
			Player.transform.position = Position.position;
		}
	}
}

function Update()
{
	if(delay > 0 && IsInRange)	delay -= 1*Time.deltaTime;
	if(delay < 0)	delay = 0;
}

function OnTriggerExit()
{
	IsInRange = false;
}

Okay, so after sleeping I finally found out what was wrong with my teleportation script. There was nothing wrong with it! The only problem was that the second teleport had it’s destination in the volume of the first teleporter, this means that the second teleporter did transfer the player to the right place, but before anyone could notice it, the first teleport transfered him again. So I just made the first teleporter to disable after the first transmission, and it is working now correctly :slight_smile: