calling a function from another script

Hi,

I have two scripts attached to one prefab I’m trying to call a function in one of them from the other:

In the caller

   var rightLines = CheckRight.checkRight(X, Y);

in the other script named CheckRight.js:

   function checkRight(X, Y){
    ...
    return rightLines}

Any help much appreciated :slight_smile:

If you have a reference to the gameObject on which your ‘CheckRight’ script is a component, just use

checkRightGameObject.GetComponent(CheckRight).checkRight(X, Y);

Thanks,

Both scripts are attached to the same object called ‘tile’, do I need to explicitly reference ‘tile’ from one script to access its functions from the other script, if so how?

Kind Regards