So Im making a portal-like-game but i cant get past one thing. Every time I go through a orange or blue portal that I shot (It just instantiates a clone) I get teleported to were i originally built the portal’s prefab on the map.
Is there a way I can make the original coordinates equal “null” until I shoot the portal which assigns the coordinates then, and still have them link to eachother automatically?
ps. I have this code for teleporting (java):
var destination : Transform;
function OnTriggerEnter(other : Collider) {
if (other.tag == "Player") {
other.transform.position = destination.position;
other.transform.rotation = destination.rotation;
}
}
heres the code for instantiating the portals:
var portalToSpawn : Transform;
var bullet : Transform;
var time : int;
var portalIsActive : boolean;
function OnTriggerEnter(other : Collider){
if(portalIsActive == false){
gameObject.Destroy(gameObject, 1.0);
portalIsActive = true;
Instantiate(portalToSpawn, transform.position, transform.rotation);
}
}