Script can't call another script's function

Hi, I’d appreciate some help. I’m trying to call a function but it won’t let me because it can’t find it.

This is where the functions are defined:

    public void ThrustUp()
    {
        m_parentDriller.rigidbody2D.AddForceAtPosition(thrust, transform.position);
	    CreateThrust(transform.position + transform.up*-0.5f, transform.up*-4.0f, 1.0f);
        m_diller.CurrentHeat += thrustHeatAmount;
    }

    public void ThrustDown()
    {
        m_parentDriller.rigidbody2D.AddForceAtPosition(-thrust, transform.position);
        CreateThrust(transform.position + transform.up * 0.2f + transform.right * 0.4f, transform.up * 3.0f, 0.5f);
        CreateThrust(transform.position + transform.up * 0.2f - transform.right * 0.4f, transform.up * 3.0f, 0.5f);
        m_diller.CurrentHeat += thrustHeatAmount;
    }

This is where they are called:

if (transformCache.position.y > 1)
        {
            driller.ThrustUp();
        }
        if (transformCache.position.y < 1)
        {
            driller.ThrustDown();
        }

This is also in the script above:

public GameObject driller = GameObject.Find("DrillerEngine");

instead of making the driller variable a GameObject, make it the type driller( assuming that is the name of the script you are trying to use it’s function)
and then make it be the component of the script in the object, so:

public driller driller = GameObject.Find("DrillerEngine").GetComponent("driller");

Hello there. Try these steps:

  1. Check if the compiler actually finds your driller gameobject. I typically advise you to use GameObject.FindGameObjectWithTag(“”); instead of Find because tags are more precise (less room for spelling errors). And if you want to have best performance and least issues, just define the driller gameObject in your Awake() and assign the gameobject in editor.

  2. call your function by using “as” and whaterver. By this i mean:

public GameObject DrillerGameObject;
 //assign this is editor
public driller Driller;

void Update() {
if (whateverconditionyouwant) {
Driller = (DrillerGameObject.GetComponent("driller") as driller;
Driller.whateverfunctionyouwannacall();
}
}

That should work perfectly

Thanks for helping me solve this issue guys.