dissable gameobjects

im atempting to dissable game objects from inside a script atached to a diffrent game object. iv looked through the API and multilpe forum posts but none of the solutions work for me. is there a way i can issable gameobjects from a diffrent gameobject?

(im a noob and the solution is probobly really simple but i cant see it)

You just get a reference to the other GameObject and call SetActive(false) on it. Since you’re a newbie, I’m assuming the problem you’re running into is getting a reference to the other object. That’s the thing new people seem to struggle with the most.

The simplest way to do this is create a public GameObject field and drag the object you’re interested in disabling into that field in the inspector.

ooohhhh ok
so the actual line of code would be like…

Public GameObject test;

  • test = SetActive(false);
    or
  • test.SetActive(false);
    ?
    or somthing more like
    GameObject.SetActive(false); ?

This one: test.SetActive(false);

thankyou i figured it out right before i looked back at this post xD (sorry)

1 Like