Why are my teleporters not working?

Hi there,

I’m an absolute novice with Unity, I began working in it for a university project about 3-4 weeks ago and I’ve just started getting into scripting.

I’m having real trouble getting multiple teleporters to work. I have two collision boxes set to teleport the player when they enter, each has its own empty game object set as it’s target, however no matter which one I take i am always teleported to the most recent one I made, each has its own individual name. The script I am using is as follows:

var target : Transform;

function Update () {

}

function OnTriggerEnter (col : Collider) {

if(col.gameObject.tag == “teleport”) {

this.transform.position = target.position;

}

}

Please help!

Thanks,

-Tom

Have you checked you assigned your target variable "correctly"? Just click the "variable value" and the linked object will be highlighted. If both teleports to the same position, i guess both are referencing the same target.

Thanks for your help, I've settled for making each teleporter its own script and that works fine.

Arg :D I just realized that you have this script on your player. A teleport script should naturally be on the teleporter object and it should teleport the object that enters the trigger. Again take a look at my example ;)

1 Answer

1

Take a look at my answer on this question

Hi, thanks. I'm not sure if this helps though, I'm not trying to make a two way teleporter, I'm trying to have two seperate teleporters that go to two separate locations :)