How can i Delete original Keep Clone
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);
}
}
Answer by ADAMN721 · Apr 28, 2017 at 03:15 PM
Your problem may be that you are not modifying the value destroyObj at any point. I don't see anywhere that this condition would ever be changed to true.
Your answer
Follow this Question
Related Questions
Why Original GameObject Destroy Clones ? 0 Answers
How remove/delete/destroy an element from an array by value in c#? 2 Answers
How do I delete objects in an animation in a certain order? 1 Answer
How to delete prefab clones?,Can I delete Trail Renderer prefab clones? 2 Answers
Destroy the first instantiated clone after 4 have been instantiated 1 Answer