Affect Script Variables using Triggers


I am trying to implement a feature into a first person shooter where certain areas decrease the accuracy of the player. Right now the script on the weapon has two open variables which control the accuracy in the x and y direction.

var projectile : Rigidbody;
var speed = 20;
var randomMin = -0.5;
var randomMax = 0.5;

function Update () {
    if( Input.GetButtonDown("Fire1") )
        var instantiatedProjectile : Rigidbody = Instantiate(
            projectile, transform.position, transform.rotation );

        var randomNumber = Random.Range(randomMin, randomMax);

        instantiatedProjectile.velocity =
            transform.TransformDirection( Vector3( randomNumber, randomNumber, speed) );

        Physics.IgnoreCollision( instantiatedProjectile. collider,
            transform.root.collider ) ;


I want a trigger to change the variables randomMin and randomMax, but I'm not sure how I can make the trigger change the open variables in the launcher script. I guess in short, I am trying to call a script and change open variables using OnTriggerEnter.

Thanks in advance!

Use GetComponent() to acquire a reference to the script/component, and then modify the variables as needed.

You can check the answers from this question for a more detailed explanation: