How do i change collider true/false using c# script in a different game object?

So basicly, i was working with the roll a ball game tutorial and wanted to add some level design and such, and i wanted to make a simple door that was “opened” once the player collected 30 coins (or pickups as the tutorial calls them).

It would go like this:

player gets 30 coins &
door’s collider becomes false.

but i cant find the code to do this, and since my code for the pick ups is in the same script as my controller i cant use “count” to control the door. please help!!

Hi,
There are various ways to do this. The easiest will be to add your door to your my controller script and then disabled the gameobject from there (or move the door if you prefer).

In the declaration part of your my controller script add:

public GameObject theDoor;

then in unity editor drag and drop the door gameobject to this item in the script inspector

then in your script do something like

if(countOfCoins>30)  //or the right name of the variable tracking your coins
{
theDoor.SetActive(false);
}

this will simply deactivate the gameobject (hide it) when you get 30 coins
hope that helps,