Turning on and off Rigidbody programmatically?

Here is a code snippet I found that should turn off and on gravity (changing the bool)

function OnTriggerEnter (other : Collider)
{
    if (other.attachedRigidbody)
    {
        other.attachedRigidbody.useGravity = true;
    }
}

I would like to know how to make it turn on the gravity of a specific object when another object collides with the trigger. THanks in advance.

So you want to do what that code does, but only selectively, instead of for everything. That would be:

function OnTriggerEnter (other : Collider)
{
    if ((other.attachedRigidbody)&&(other.tag == "gravObject"))
    {
        other.attachedRigidbody.useGravity = true;
    }
}

Or if you want the gravity to change for ObjectA when ObjectB hits TriggerC. which would be:

var gravObject : Transform;

function Awake()
{
    gravObject = GameObject.FindWithTag("GravObject").transform;
}

function OnTriggerEnter (other : Collider)
{
    if (gravObject.rigidbody)
    {
        gravObject.rigidbody.useGravity = true;
    }
}

Create a reference to the `GameObject` that's supposed to get gravity and reference that in your trigger:

var gravityObject : GameObject;

function OnTriggerEnter(other : Collider)
{
    if(gravityObject!=null && gravityObject.rigidbody!=null)
        gravityObject.rigidbody.useGravity = true;
}

That code turns the gravity on to the "other" which is the gameObject which has entered the gameObjects trigger. Have you got RigidBody attached to the other gameobject ? with gravity unchecked ?