Making a moving teleporter move to co-ordinates when it teleports something

Right now when my Character hits my Enemy’s collider he teleports back to a pont in my map but he can get to the point where my enemy has him stuck at his spawn. Is there a way i can make it so that when my enemy triggers the teleport he also teleports back to a spawn of his own.

Here is the Teleport Script:

var target : Transform;

function Update () {

}

function OnTriggerEnter (col : Collider) {

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

this.transform.position = target.position;

}

}

Is this script attached to the player or the enemy ? And what is tagged "teleport" ? The enemy ?

if the enemy is the trigger and the player has the script, why do you check if col.gameObject.tag is equal to teleport ? The tag teleport should be on the target game object right ?

1 Answer

1

The player has the script, enemy is the trigger and there is a seperate gameobject tagged “teleport” (where the player teleports to)

Don't answer your own question, edit it or post a comment.