Search Unity

Help with disabling an objects renderer when a trigger is activated.

Discussion in 'Scripting' started by Deathassassin05, Jan 4, 2014.

  1. Deathassassin05

    Deathassassin05

    Joined:
    Jan 4, 2014
    Posts:
    2
    Hi, today I come to you, the unity community with a simple problem(That I'm completely embarrassed to be asking..).
    In my game, I have where a player walks down a hallway, that leads to a dead end, at the dead end, I have a box collider set to the trigger form, I am trying to create a script that disables the lights going down this hallway when the enters the trigger, but I don't know the script, or what I should put the script into(the trigger, the lights, or the player.) I am aware of the "renderer.enabled = false;" code, and I would like for it to be implemented in this.
    Help me, please? :)
     
  2. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    You probably just want to set enabled = false on the lights, disabling the renderer will stop geometry from being drawn which doesn't sound at all to be the result you want.

    If you're having trouble figuring how how and where to place scripts and associate game object instances with them then this is more of a general Unity understanding issue, and a bit out of scope for the forum. I strongly recommend you follow some tutorials that cover setting up triggers, scripts and object references using public fields and the inspector.
     
  3. Deathassassin05

    Deathassassin05

    Joined:
    Jan 4, 2014
    Posts:
    2
    After little dabbling in other peoples code I compiled my own, which worked, thank you for answering me though :)
    as you said,
    Code (csharp):
    1.  GameObject.SetActive(true/false);
    did the trick :3