Link 2 variables from 2 different scripts to 3rd script

Hello, I’ve asked a question here before because I didn’t understand how to link a variable from another script. But my next question is how to get another variable to that script to. By example:

testInput.js

var testVariable = 1;

var to : testOutput; // Assign it in the inspector



function Update()

{

    if( Input.GetKey("k") )

    {

        testVariable= 5;

        to.UpdateAnotherVariable( testVariable );
    }

}

testOutput.js

var anotherVariable = 0;



function UpdateAnotherVariable( i : int )

{

	if( i == 5)

	{

		if()// if finalVariable from finalScript.js == 10. (here is the

problem)

		anotherVariable = 1;

	}

}

finalScript.js

var finalVariable = 5



function Update

{

	if(finalVariable == 5)

	{

		finalVariable = 10;

	}

}

Sorry for all that spaces, but that’s because of a problem with the editor :S.

So you can try this - note you should really call it FinalScript to indicate that it is a class. Drag and drop your final script object onto test output.

var anotherVariable = 0;
var final : finalScript;
function UpdateAnotherVariable( i : int )
{
    if( i == 5)
    {
       if(final.finalVariable == 10 {
            anotherVariable = 1;
        }

    }

}