script syntax

Hey guys,

I’m trying to get the code below to work, but having little success. What can I do to get this to work? The part that is not working is once 4 cubes are destroyed gravity should turn on for the remaining cubes so they fall:

var smokePrefab: Transform;
var int objectDestroyed = 0;

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

 }
 {
 if objectDestroyed == 4;
 {
 gameObject.rigidbody.useGravity = true;
 }
}

Sorry for the ugly code, I’m new to scripting.

Thanks,

Stef

You are enabling gravity for the gameObject you destroy, that won’t do much. You probably need to get an array of the remaining cubes, preferably with a tag and a Find function, then set rigidbody.useGravity = true; on those guys.