Search Unity

Make an object invisible from script

Discussion in 'Scripting' started by v_chs, Sep 21, 2020.

  1. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    64
    Is it possible to make a game object invisible? I tried to change the opacity of the material's color but it still appears in the scene.
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    To make a gameobject invisible you can disable its renderer component. If you dont need the object in the scene right now (including script functionality) you may also just disable the entire gameobject.
     
    Jwaldron90 and v_chs like this.
  3. cate5171

    cate5171

    Joined:
    Jan 5, 2020
    Posts:
    101
    One way you could do it is to deactivate the game-object during the script so it doesn't appear in the scene:
    Code (CSharp):
    1. public GameObject OBJECT1;
    2.  
    3. void Update();
    4. {
    5.  // Collision/Way to Trigger
    6.   OBJECT1.SetActive(false);
    7.     }
    8. }
     
    Quark_Gluon1 and v_chs like this.
  4. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    64
    I want to make it invisible but listen to onTriggerEnter events.
     
    jeremylamb likes this.
  5. v_chs

    v_chs

    Joined:
    Dec 11, 2019
    Posts:
    64
    I want to make it invisible but listen to onTriggerEnter events.
     
  6. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
  7. jeremylamb

    jeremylamb

    Joined:
    Mar 1, 2022
    Posts:
    1
    thankyou