Unity Damage game object with tag after changing tag of current one.
Hi , I am working unity2D project and stuck in mechanics. in my game player can go left and right and and ground is finite and if player reaches left end then another left ground will created as clone and vice versa but there is also one destroy trigger which will destroy the last ground and same concept goes with other one but if user come back and call current destroytrigger then the created one will be destroyed but in my case the first one always destroy whether i am colliding with first trigger or trigger associated with created one Here is the script i am using any help will be much apppreciated:
void OnTriggerEnter2D(Collider2D other) {
if(other.tag=="destroy"){
this.transform.gameobject.tag = "notdestroy";
Destroy(gameObjectWithTag("destroy"));
this.transform.gameobject="destroy"
}
if(other.tag=="create") {....//create the object as per trigger
}
}
please don't rectify my syntax error the script i am using in my project is correct and i think what it is doing wrong that after trigger it will destroy the first object which is current one and clone also has same script so it is doing same thing with clone
Your answer
Follow this Question
Related Questions
How to display ad after some time? 0 Answers
Set the username with an inputfield ? 3 Answers
Unity UI Test Automation displays error, after compiling 0 Answers