Basically I have a pixelated creature made up of these cubes and when hit by a bullet I want them to fall apart. So heres the code I wrote but for some reason it does not work.
var thePrefab : GameObject;
function OnTriggerEnter (myTrigger : Collider) {
if (myTrigger.gameObject.name == "bullet(Clone)"){
var count : int = 0;
while (count <= 20){
var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation);
count++;
}
Destroy(gameObject);
Destroy(myTrigger.gameObject);
}
}