Hello there I am making a Game where you enter a Trigger the Floor will spawn in front of you and the original one AKA the Last one will destroy itself but i cant seem to destroy the last GameObject here it what I have so far PS: i am using JavaScript
#pragma strict
var destroyObj : boolean = false;
var DuplicateObj : boolean = false;
var Room1 : GameObject;
var DisX : float;
var DisY : float;
var DisZ : float;
function Start () {
}
function Update () {
}
function OnTriggerEnter (other : Collider) {
if (DuplicateObj==true) {
for (var i: int = 0; i < 1; i++) {
Instantiate(Room1, new Vector3(i * DisX, DisY, DisZ), Quaternion.identity);
}
}
if (destroyObj==true){
var clone = Instantiate (original, transform.position, Quaternion.identity);
Destroy (clone, 1.0);
}
}