I am trying to remove a rigidbody from an instantiated object after x more are instantiated after it.Here is my script :
public var cube : Transform;
public var cubeclone : Transform;
public var counter;
function Update () {
if (Input.GetButtonDown("Fire1")){
var count = counter;
cubeclone = Instantiate (cube, Vector3 (transform.position.x, transform.position.y, 0), Quaternion.identity);
transform.position.y += 0.5;
counter++;
if (counter == count + 4) {
Destroy(cubeclone.rigidbody);}
}
}
Also the script only instantiates a cube if counter++ is at the bottom like it is now. Any help would be appreciated.