- Home /
 
 
               Question by 
               benjagal · Nov 18, 2011 at 11:40 PM · 
                instantiatecollidervariables  
              
 
              Problem trying to access values from another object script
Well, actually I'm trying to do many things and I've had really a lot of trouble trying to just access the otherscript variables
Here i want to check if the entering collider has a "unitControl" script, then i want to check for the value of the variable "isUnit" located inside the "unitControl" script.
 function OnTriggerEnter ( other : Collider ) {
 
      if (other.GetComponent(unitControl)){
 
         if (other.GetComponent(unitControl).isUnit == true){
     
         //Here i do many things that work perfectly, had to add the check to
             //avoid many trash targets.
         }
     }
 
               }
Here i want to assign the projectile damage by checking the damage the unit does.
 var Damage = 1;
     function Atacar(segundos) {
         if(segundos!=savedTime){
             savedTime=segundos;
             var projectile = Instantiate(wpnType, 
                                 transform.Find("attackPoint").transform.position , 
                                 Quaternion.identity);
                 projectile.rigidbody.AddForce(transform.forward * throwForce);
                 projectile.getComponent(projectileScript).projectileDamage = Damage;
         }
     }
 
               Yet, all i get is Null references exeptions :/. I'v trying over and over the script reference examples but none seems to point how to get my variable value from another script variable. :C hope u can help me!
               Comment
              
 
               
              Your answer