I need to delete an instated gameObjects clone once I instate it again, for example if a person were to place a block, the next time that person would place that same block the original would become destroyed. How would one do this?? what is the theory behind the code?
I’ve tried using static variables and some very complex methods to not much avail.
When you instantiate the first block give it a a name. Then when you instantiate the second block, check if that name exists, if so delete it and assign the second block to the name.
function PlaceBlock(){
var clone : GameObject;
if(clone!= null){
Destroy(clone);
clone = instantiate.........
}
else
clone = instantiate.........
}
this will give you errors but you get the idea right?