first, sorry for bad english,
Im having trouble trying to destroy a clone, my clone have a script attached to him, so in the script i have this code:
if (this.transform.position.y <= MainCameraScript.altura.y - 90){
Destroy(this.gameObject);
}
that code actually destroy the gameobject, but dont destroy the prefab clone and i have a bunch of empty clones.
any can help me? thanks in advance
so, there is no way to destroy the clone in their own attached script? :s
– rubenpvargasYou can destroy any object from any script -- just call
– rutterDestroy()with a reference to the target. It's really more of a question of deciding which object to destroy when. "Self-destruct" calls, in which a script destroys itself or the GameObject it's attached to, are pretty common... but that's not a requirement. Which objects are you trying to destroy, and when do you want to destroy them? Once you've answered that, the path gets a little bit less murky.ok, thanks. I think i need to put the destroy code in the "spawnScript" for do it more easy. Thanks.
– rubenpvargas