- Home /
Is this code right?
I am trying to make all the objects under a parent go invisible when i press I can someone please tell me why this isn't working. Thanks.
function update ()
{
if(Input.GetKeyDown(KeyCode.I))
{
transform.FindChild("Cave").GetComponent(Renderer).enabled = true;
}
}
try replacing 2 lines:
function Update ()
and
transform.FindChild("Cave").GetComponent<Renderer>().enabled = false;
you want it to get invisible right not visible, ...
Note, sdgd wrote in C#, OPs looks like JS
function update () also needs a capital U
function Update() {}
By not putting a capital letter an error will not be thrown as you have legitimately created a new custom function by the name of update.
that's why I wrote in comment
I can't write java and I barely read it
but still he has to make it false if he wants to disable the render
and what the hell OP means? I've been seeing it for too many times - I aint writing a question for that
Indeed you are correct, that I do not dispute :)
The GetComponent JS OP wrote looks right in syntax, so what he wrote, with your correction :)
@sdgd - OP means "Original Poster" - the person who started this thread, I.e. Ez64cool
Your answer
Follow this Question
Related Questions
Is it possible to do 'click to move' in the free version of Unity 1 Answer
Creating Arrays 0 Answers
how to do complete script function in Mono IDE? 1 Answer
Quick Question on State Machine 1 Answer
Help with Enemy Spawner! 1 Answer