light on due to mass size

Hi All,

been getting a head ache from trying to work this out.

I have attached this script to an object.

 var myLight : Light;
 var myMass : mass;

  function start() {
     var myLight = GameObject.Find("myLight").light;
     var myMass = GameObject.Find("myMass").rigidbody.mass;
 }

im using the vars to target a specific light in the group and also the mass to target the mass of the object.

I need to add some lines to the code that when the mass passes a value the light will turn on. I've been trying and i think i keep walking in cirlces and the red error text is starting to hurt my eyes.

Sorry if this is a silly question, but i hope some one can help me.

Thank you

It looks like you are trying to store the value of the `Rigidbody`'s mass during `Start()` but then if you compare against it later that value will never change. You'll want to set a variable to be the `Rigidbody` then `myRigidbody.mass` during `Update()` will get the actual mass of the `Rigidbody` every frame.

Then it's a simple matter of comparing the mass to the threshold you want the light to turn on at and then setting the `Light`'s `enabled` property.


Using the inspector is usually easier/less-error-prone than using `GameObject.Find` not to mention faster.


when you declare the variable `myMass` in your script you are saying it is of the type `mass` which is not actually a type. A `Rigidbody`'s `mass` property is a `float` value.