I have 3 blocks. I have a script where when I look at a block I want it to delete the other 2 blocks. However these two blocks are variables in my script so when they are deleted in game the script is still trying to look for them and obviously they are not there any more so the game crashes. How can I make it so as well as deleting the 2 other blocks it removes the variables from the script. I have this script on all three blocks so which ever one I look at the other two are deleted. Here’s my script:
var Girl : GameObject;
var spawnPoint : Transform;
var Block : GameObject;
var Block2 : GameObject;
function OnBecameVisible(){
var clone;
clone = Instantiate(Girl, spawnPoint.position, spawnPoint.rotation);
Destroy(Block);
Destroy(Block2);
}
For each Block the variables Block and Block 2 are the other two blocks, any help would be great! Thanks.