How to reference GameController

I have an object called GameController which contains lots of public variables that are accessed by other objects.

My issue is that I can’t seem to find a way to reference my GameController without dragging and dropping into the inspector.

More details:
I have this bit of code before Start();

    public GameController gameControllerObj;
    public Transform controllerLocation;

I am then able to manually reference the transform controllerLocation by doing the following:

controllerLocation = GameObject.FindGameObjectWithTag("SpawnerTag").transform;
gameControllerObj = GameObject.FindGameObjectWithTag("GameController");

The second line in this bit is where I am having my issue. How do I reference my GameController which is tagged “GameController”. Is it not with GameObject?

Any help will be much appreciated. Been stumped on this one for a while now.

Hi !
Better late than never :wink:

For the second line you must explicitly make a reference to your script using :

gameControllerObj = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>();