I’m using projectiles to destroy chunks out of a wall. Once 100 chunks have been destroyed I’d like to turn gravity ‘on’ so the wall collapses. Having a hard time getting 'er done. Here’s my script. Any thoughts for a scripting noob?

function OnCollisionEnter(collision : Collision) 
	if (collision.gameObject.tag == "missile_1")
		Destroy (gameObject);
		//Instantiate (smokePrefab, transform.position, transform.rotation);
		//Instantiate (Sphere, transform.position, transform.rotation);
		objectDestroyed++ ;
		print (objectDestroyed);

	if( objectDestroyed >= 100)
     	gameObject.rigidBody.useGravity = true;



I’m going to assume you have this script on each of your “wall blocks” that you want destroyed. If that’s the case, the real problem is that you have a different objectDestroyed variable in each script. There’s no cumulative counter.

You need to have a script that keeps track of that sort of thing on an object that isn’t going to be destroyed. (invisible gameobject would be fine). Each time a block gets destroyed, have it modify the objectDestroyed variable in that “master” script. Then check against that variable in your Update function to determine when to flip on gravity.